import java.io.RandomAccessFile; import java.io.*; import java.util.StringTokenizer; public class Kodutoo1{ public static void main (String argumendid[]) throws IOException{ String rida ; BufferedReader klaviatuur=new BufferedReader( new InputStreamReader(System.in)); System.out.println ("Palun failinimi:"); String failinimi=klaviatuur.readLine(); System.out.println ("Palun sona"); String sona=klaviatuur.readLine(); RandomAccessFile rf=new RandomAccessFile(failinimi,"r"); // BufferedReader rf=new BufferedReader( // new FileReader (failinimi) // ); rida=rf.readLine(); while(rida!=null){ StringTokenizer st=new StringTokenizer(rida," "); while(st.hasMoreTokens()){ String s=st.nextToken(); if(s.indexOf(sona)>=0){ System.out.println(s); } } rida=rf.readLine(); } rf.close(); System.out.println("edasi"); for(int koht=0;koht<=sona.length()-2; koht++){ System.out.println(koht); sonad(sona.substring(koht,koht+2), failinimi); } } static void sonad(String tahed, String failinimi)throws IOException{ System.out.println(tahed); RandomAccessFile rf=new RandomAccessFile(failinimi,"r"); String rida=rf.readLine(); while(rida!=null){ StringTokenizer st=new StringTokenizer(rida," "); while(st.hasMoreTokens()){ String s=st.nextToken(); if(s.indexOf(tahed)>=0) { System.out.println(s); } } rida=rf.readLine(); } rf.close(); } }