import java.io.*; import java.io.IOException; import java.util.StringTokenizer; public class minu1{ //reads the text file as one "big word" static String readFile Fail(String failinimi) throws IOException{ StringBuffer sb=new StringBuffer(); RandomAccessFile rf=new RandomAccessFile(filename, "r"); String row=rf.readLine(); while(row!=null){ sb.append(row+" "); row=rf.readLine(); } int len=sb.length(); sb.delete(leng-1, len); return new String(sb); } //changes the "big word" into the sentence array static String[] intosentences(String s){ StringTokenizer st=new StringTokenizer(s, ".?!", true); String sentences[] = new String[st.countTokens()]; int place=0; while(st.hasMoreTokens()){ sentences[place++]=st.nextToken(); } return sentences; } //counts how many words are in the sentence static int count(String sentence, String word){ int nr=0, firstplace=0; while(firstplace=0){ nr++; firstplace=place+word.length(); }else firstplace=sentence.length(); } return nr; } //asks the file name or word from user static String askAnswer(String question) throws IOException{ System.out.println(question); BufferedReader br=new BufferedReader( new InputStreamReader(System.in) ); return br.readLine(); } //asks the filename and the word //counts how many times the word was at the beginning of the sentence public static void main(String argumendid[]) throws IOException{ String filename=aksAnswer("Type the file name please:"); String word=askAnswer("Type the word please:"); String sentencearray[]=intosentences(readFile(filename)); int number=0; for(int i=0; i