Advertisement
Guest User

Untitled

a guest
May 28th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4.  
  5. public class WordsFrequencyDemo {
  6.     public static void main(String [] args){
  7.         try {
  8.             WordsFrequencyTree tree=new WordsFrequencyTree();
  9.             String s=args[0];
  10.             BufferedReader input=new BufferedReader(new FileReader(s));
  11.             while(input.ready()){
  12.                 String st=input.readLine();
  13.                 StringTokenizer tok=new StringTokenizer(st," ,.*;:\\|/\n\t");
  14.                 while(tok.hasMoreTokens()){
  15.                     tree.add(tok.nextToken());
  16.                 }
  17.             }
  18.             System.out.println("Parola minore alfabeticamente " + tree.lessAlph());
  19.             System.out.println("Parola maggiore alfabeticamente " + tree.grtAlph());
  20.             tree.printWords();
  21.         } catch(ArrayIndexOutOfBoundsException e) { System.err.println("Parametri non validi!"); System.exit(-1); }
  22.         catch(FileNotFoundException e){ System.err.println("Non trovo il file."); e.printStackTrace(); System.exit(-2); }
  23.         catch(IOException e){ System.err.println("Errore accesso al file."); e.printStackTrace(); System.exit(-2); }
  24.         catch(NullPointerException e) { System.err.println("L'albero รจ vuoto. Controlla il file input."); System.exit(-3); }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement