我正在写一个文件,想要控制台输出,
// TODO Create a game engine and call the runGame() method
public static void main(String[] args) throws Exception {
NewGame myGame = new TheGame().new NewGame();
myGame.runGame();
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
}
这给了我控制台输出,但它抛出以下异常:
java.io.FileNotFoundException: TheGame.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at game.main(TheGame.java:512)
该文件确实存在.