교수형 집행자 프로그램에 문제가 있습니다. 정말 내가해야 할 일은 내가 자바에 대해 이해할 수있는 것 이상이라고 생각합니다. 여기에 내 코드파일 내용을 배열에 저장하는 중
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Random;
public class HangmanProject
{
public static void main(String[] args) throws FileNotFoundException
{
String scoreKeeper; // to keep track of score
int guessesLeft; // to keep track of guesses remaining
String[] wordList = new String[25];
final Random generator = new Random();
Scanner keyboard = new Scanner(System.in); // to read user's input
System.out.println("Welcome to Nick Carfagno's Hangman Project!");
// Create a scanner to read the secret words file
Scanner wordScan = null;
try
{
wordScan = new Scanner(new BufferedReader(new FileReader("words.txt")));
while (wordScan.hasNext())
{
}
}
finally
{
if (wordScan != null)
{
wordScan.close();
}
}
// get random word from array
class pickRand
{
public String get(String[] wordList)
{
int rnd = generator.nextInt(wordList.length);
return wordList[rnd];
}
}
System.out.println(wordList);
}
}
내가 파일을 읽은 다음 화면으로 인쇄 할 수있는 프로그램을 얻을 수 있었다, 그러나 나는 배열로 파일에서 단어를 저장하는 방법을 알아낼 수 없습니다. 나는 전혀 발전하지 않았으므로되도록 철저히 노력하십시오. 지금까지있어 무엇
가능한 복제본 : [Java : 배열로 파일 읽기] (http://stackoverflow.com/questions/285712/java-reading-a-file-into-an-array?rq=1) – Baz
[ Scanner에 대한 Java 자습서] (http://docs.oracle.com/javase/tutorial/essential/io/scanning.html). – assylias
지난 주에 똑같은 일이 5 번이나 게시되었습니다 ... 정확히 똑같은 것, 그 둘 사이의 유일한 차이점은 누가 행맨 프로젝트 인 지요, 롤 –