Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. // The name of the file to open.
  2. String fileName = "Sn.txt";
  3. // User input for the location
  4. String UserInput = "10AZ";
  5. String CheckCharacter;
  6.  
  7. //RC method finds the check character for the location
  8. CheckCharacter = Check2.RC(UserInput);
  9.  
  10. //getPhonetic gives back the phonetic associated with check character
  11. String NewCC = Check2.getPhonetic(CheckCharacter);
  12.  
  13. String line = null;
  14. try {
  15. FileReader fileReader =
  16. new FileReader(fileName);
  17. // Always wrap FileReader in BufferedReader.
  18. BufferedReader bufferedReader =
  19. new BufferedReader(fileReader);
  20. int count =0;
  21. while((line = bufferedReader.readLine()) != null) {
  22. if(line.endsWith(NewCC)) {
  23. count++;
  24. System.out.println(line);
  25. //System.out.println(isAnagram(UserInput, line) + "USER INPUT");
  26. }
  27. //System.out.println(line);
  28. }
  29. System.out.println(count);
  30. bufferedReader.close();
  31. }
  32. catch(FileNotFoundException ex) {
  33. System.out.println("Unable to open file '" + fileName + "'");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement