import java.io.*; import java.util.StringTokenizer; public class aaa{ public static void main(String argumendid[]) throws IOException{ BufferedReader klaviatuur=new BufferedReader( new InputStreamReader(System.in) ); System.out.println("Palun failinimi:"); String failinimi=klaviatuur.readLine(); System.out.println("Palun täht"); String taht=klaviatuur.readLine(); BufferedReader sisse=new BufferedReader( new FileReader(failinimi) ); String rida=sisse.readLine(); char c = taht.charAt(0); int max = -1; String maxsona = null; while(rida!=null){ StringTokenizer st=new StringTokenizer(rida, " "); while(st.hasMoreTokens()){ String sona=st.nextToken(); int x = 0; for(int i=0; i < sona.length();i++) { if (sona.charAt(i) == c) { x++; } } if (max < x) { max = x; maxsona = sona; } } rida=sisse.readLine(); } System.out.println(maxsona); } }