Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int line = 1;
- try
- {
- FileReader fr = new FileReader(getFileName()+".txt");
- BufferedReader br = new BufferedReader(fr);
- String a = br.readLine();
- String b = "";
- while(a != null)
- {
- StringTokenizer st = new StringTokenizer(a);
- while(st.hasMoreElements())
- {
- b = st.nextToken();
- if(bst.size() == 0)
- bst.insert(b, new WordNode(b, line));
- else if(bst.size() >= 1)
- {
- if(bst.find(b) == null)
- bst.insert(b, new WordNode(b, line));
- else
- bst.find(b).getValue().addLine(line);
- }
- }
- line++;
- a = br.readLine();
- }
- }
- catch(FileNotFoundException fnfe)
- {
- System.out.println("File not found!");
- }
- catch(IOException ioe)
- {
- System.out.println("Error!!");
- }
- return bst.size();
Add Comment
Please, Sign In to add comment