[問題] 為什麼開啟後的檔案內容都不見了!?
請各位大大幫我看一下:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class TransferFile {
public static void main(String[] args) {
File file = new File(args[0]);
try {
FileInputStream fis = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
System.out.println(br.readLine());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
為什麼當我執行java TransferFile c:\leo.txt後,leo.txt的檔案內容都被清空,
而且無論我檔案內容有幾行程式都只顯示一行呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.251.100.51
推
08/17 16:41, , 1F
08/17 16:41, 1F
→
08/17 17:08, , 2F
08/17 17:08, 2F
推
08/17 22:15, , 3F
08/17 22:15, 3F
→
08/17 22:19, , 4F
08/17 22:19, 4F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):