import java.io.RandomAccessFile; import java.io.IOException; import java.io.*; import java.util.StringTokenizer; public class minu{ public static void main (String argumendid[])throws IOException{ String rida; BufferedReader klaviatuur=new BufferedReader( new InputStreamReader(System.in) ); System.out.println("Palun sona"); String sona=klaviatuur.readLine(); RandomAccessFile rf=new RandomAccessFile(argumendid[0],"r"); rida=rf.readLine(); String tekst=""; // String rida=rf.readLine; while(rida!=null){ tekst=tekst+rida; rida=rf.readLine(); } int lugeja=0; StringTokenizer jagaja=new StringTokenizer(tekst,".!?"); while(jagaja.hasMoreTokens()){ String lause=jagaja.nextToken(); int koht=lause.lastIndexOf(" "); String viimane=lause.substring(koht+1); if(viimane.equals(sona)) lugeja=lugeja+1; } System.out.println(lugeja+" korral säna asub lause läpus "); }}