0
import java.util.*;
import java.io.*;
public class Hangman {
    public static void main (String [] args) throws IOException{
        // importing file for wordbank
    //  File wordbank = new File("words.txt");
        Scanner scan = new Scanner( new File ("words.txt"));

        String [] wordBank = new String [20];

        while ( scan.hasNext() ){
            for(int x = 0; x < 10; x++){
                String line = scan.nextLine();
                wordBank[x] = line;
            }

        }
        System.out.println( wordBank[1]);

    }
}

my error are below. Im not sure what this means.

Exception in thread "main" java.io.FileNotFoundException: words.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.util.Scanner.<init>(Unknown Source)
    at Hangman.main(Hangman.java:8)
Pshemo
  • 122,468
  • 25
  • 185
  • 269
zman22
  • 1

1 Answers1

0

You need to add a file called words.txt (containing your json data) in the same directory as the java file you are running. Also uncomment the line that says

File wordbank = new File("words.txt");

lukegary
  • 108
  • 4