use*_*085 8 java eclipse filenotfoundexception
我正在写一个文件,想要控制台输出,
// 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);
}
Run Code Online (Sandbox Code Playgroud)
这给了我控制台输出,但它抛出以下异常:
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)
Run Code Online (Sandbox Code Playgroud)
该文件确实存在.
Men*_*los 15
该文件应包含在项目的根目录中.
在eclipse中执行项目时,工作目录是项目的最高级别.
右键单击您的项目,单击"新建">"文件",然后创建一个名为"TheGame.txt"的txt文件.
| 归档时间: |
|
| 查看次数: |
49105 次 |
| 最近记录: |