Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class WordsFrequencyDemo {
- public static void main(String [] args){
- try {
- WordsFrequencyTree tree=new WordsFrequencyTree();
- String s=args[0];
- BufferedReader input=new BufferedReader(new FileReader(s));
- while(input.ready()){
- String st=input.readLine();
- StringTokenizer tok=new StringTokenizer(st," ,.*;:\\|/\n\t");
- while(tok.hasMoreTokens()){
- tree.add(tok.nextToken());
- }
- }
- System.out.println("Parola minore alfabeticamente " + tree.lessAlph());
- System.out.println("Parola maggiore alfabeticamente " + tree.grtAlph());
- tree.printWords();
- } catch(ArrayIndexOutOfBoundsException e) { System.err.println("Parametri non validi!"); System.exit(-1); }
- catch(FileNotFoundException e){ System.err.println("Non trovo il file."); e.printStackTrace(); System.exit(-2); }
- catch(IOException e){ System.err.println("Errore accesso al file."); e.printStackTrace(); System.exit(-2); }
- catch(NullPointerException e) { System.err.println("L'albero รจ vuoto. Controlla il file input."); System.exit(-3); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement