Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. public class Start {
  2.     public static void main(String[] args) throws IOException {
  3.         TableHashDC<String> table= new TableHashDC<String>();
  4.         TreeMapDC<String> tree = new TreeMapDC<String>();
  5.         FileReader f = new FileReader("C:\\Users\\salva\\eclipse-workspace\\progetto\\src\\progetto\\prova.txt");
  6.         BufferedReader b = new BufferedReader(f);
  7.         String s;
  8.         String[] stringhe = new String[90];  //vedere quanto spazio ha allocato per ospitare le stringhe di una riga
  9.         while(true) {
  10.             s=b.readLine();
  11.             if(s==null)
  12.                 break;
  13.           stringhe= s.split(" ");
  14.           for(int i = 0; i< stringhe.length; i++) {
  15.               if (!table.containsKey(stringhe[i])) {
  16.                   stringhe[i]=stringhe[i].toLowerCase();
  17.                   table.insertEl(stringhe[i], 1);
  18.                   tree.insertEl(stringhe[i], 1);
  19.               } else {
  20.                   stringhe[i]=stringhe[i].toLowerCase();
  21.                   table.incCount(stringhe[i]);
  22.                   tree.incCount(stringhe[i]);
  23.               }
  24.           } //for
  25.         } //while
  26.     }//main
  27. }// class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement