Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Scanner file;
- private final List<String> words;
- public TextFile(){
- words = readFile();
- }
- public String getWord(){
- return numOfWords;
- }
- private List<String> readFile() {
- List<String> wordList = new ArrayList<String>();
- try {
- file = new Scanner(new File("words.txt"));
- }
- } catch (FileNotFoundException e) {
- System.out.println("File Not Found");
- } catch (Exception e) {
- System.out.println("IOEXCEPTION");
- }
- return wordList;
- }
- public static void main(String[] args) {
- TextFile file = new TextFile();
- }
- List<String> words; // assign stuff to words
- Random r = new Random();
- //yields random number in the range of 0 to words.size()-1 inclusive
- int num = r.nextInt(words.size());
- List<String> words; // assign stuff to words
- int index = (int)(Math.random() * words.size());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement