-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHangman.java
More file actions
32 lines (30 loc) · 771 Bytes
/
Copy pathHangman.java
File metadata and controls
32 lines (30 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package test;
import java.io.File;
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Random;
public class Hangman {
public static void main(String[] args) {
String fileName = "/Users/william/Downloads/Random.txt";
int n = 0;
ArrayList<String> x = new ArrayList<String>();
try {
Scanner sc = new Scanner(new File(fileName));
while (sc.hasNextLine()) {
String word = sc.nextLine();
System.out.println(word);
n++;
//ArrayList
}
sc.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println(n);
Random rand = new Random();
int n1 = rand.nextInt(n);
System.out.println(n1);
}
}
//write something to count total number of word in file