Thank you!!!
Expand|Select|Wrap|Line Numbers
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Random;
- import java.util.Scanner;
- public class New2
- {
- public static void main(String[] args) throws FileNotFoundException
- {
- Scanner sc = new Scanner(new File("dictionary.txt"));
- while (sc.hasNext())
- {
- String word = sc.next();
- sc.nextLine();
- String[] wordArray = word.split(" ");
- //System.out.println(Arrays.toString(wordArray));
- int idx = new Random().nextInt(wordArray.length);
- String random = (wordArray[idx]);
- System.out.println(random);
- }
- }
- }