【发布时间】:2013-09-13 14:20:11
【问题描述】:
我正在写入文件并想要控制台输出,
// 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.<init>(FileInputStream.java:138)
at game.main(TheGame.java:512)
文件确实存在。
【问题讨论】:
-
@meewoK:谢谢。让我感到困惑的是,原始发帖人从未阅读过他自己的问题,看到它没有意义,并纠正了它。
-
无意冒犯,但我们都从某个地方开始……这是我的第一堂课。
-
无意冒犯,但请记住编译器是严格且无情的。你的问题有点草率,你会想训练自己对这样的容忍度低。还发布一个体面的问题,一个易于阅读和理解的问题表明您正在认真对待您的问题、本网站和我们的帮助。我期待着随着时间的推移看到你的进步。
标签: java eclipse filenotfoundexception