我試圖讓我的程序保存輸出到一個文件進行調試。問題是,它編譯沒有任何錯誤,而不創建任何地方的文件被看到。這可能非常簡單,但我無法弄清楚,有一段時間沒有用Java編碼。OutputStream代碼沒有給出任何錯誤,但txt文件丟失
public static void main(String[] Args) {
FileOutputStream out = null;
try {
out = new FileOutputStream("out.txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
PrintWriter ps = new PrintWriter(out);
for (int l = 1; l < 1001; l++) {
ps.println((translation(makeString(l))));
System.out.println((translation(makeString(l))));
}
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
在此先感謝!
你在哪裏搜索你的文件?因爲它在執行程序的目錄中。 –
你在哪裏運行這個程序在命令行或者像IDE的Eclipse – sunleo
這樣的IDE進行檢查,雙重檢查...不在那裏!此外,我不確定它是相關的,但我使用Eclipse。也許它將文件保存在其他地方? –