Guest User

Untitled

a guest
Jun 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. int line = 1;
  2. try
  3. {
  4. FileReader fr = new FileReader(getFileName()+".txt");
  5. BufferedReader br = new BufferedReader(fr);
  6. String a = br.readLine();
  7. String b = "";
  8.  
  9. while(a != null)
  10. {
  11. StringTokenizer st = new StringTokenizer(a);
  12. while(st.hasMoreElements())
  13. {
  14. b = st.nextToken();
  15. if(bst.size() == 0)
  16. bst.insert(b, new WordNode(b, line));
  17. else if(bst.size() >= 1)
  18. {
  19. if(bst.find(b) == null)
  20. bst.insert(b, new WordNode(b, line));
  21. else
  22. bst.find(b).getValue().addLine(line);
  23. }
  24. }
  25. line++;
  26. a = br.readLine();
  27. }
  28. }
  29. catch(FileNotFoundException fnfe)
  30. {
  31. System.out.println("File not found!");
  32. }
  33. catch(IOException ioe)
  34. {
  35. System.out.println("Error!!");
  36. }
  37. return bst.size();
Add Comment
Please, Sign In to add comment