package program.p02;
import java.io.*;
import java.util.*;
import java.lang.*;
public class Dictionary {
private String[] dictionary;
private static final int NUMBER_OF_WORDS = 81452;
private static String FILE_NAME = "dictionarycleaned.txt";
//no arg constructor???
public Dictionary() {
Scanner fin = null;
//open and test the stream
try {
fin = new Scanner(new File(FILE_NAME));
}//end try
catch (FileNotFoundException e) {
System.err.println(e);
System.exit(1);
}//end catch
fin.close();
}
public String getRandomWord() {
//class random?? random number generator
Random generator = new Random(81452);
int r = generator.nextInt();
return dictionary[r];
}//end getRandomWord()
}//end dictionary class
I am having a bit of trouble with my file IO it is not reading the file apparently and I have no clue why, any one help please?
Java Code