[問題] 程式執行後無法刪除檔案
最近在寫一個搬移檔案的程式的時候
發生了無法刪除原始檔的問題
不知道是為什麼
程式碼也沒錯
但在fi.delete(); 這段跑出來的結果卻是false
我也有把FileReader、FileWriter給close掉了
結果還是不會刪,請問造成的原因會是什麼啊@@
謝謝
---------------------------以下為程式碼---------------------------------
public void Barcode_Dir(String Dir) throws IOException {
File fi = new File("oldpath");
File finew = new File("newpath");
if (fi.exists()){
WriteOfBarcode(fi.getPath());
FileReader in = new FileReader(fi);
FileWriter out = new FileWriter(finew);
int c;
while((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
fi.delete();
}
else{
util_log.OutputLog("找不到檔案");
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.70.208.96
※ 編輯: fowx 來自: 203.70.208.96 (01/17 14:06)
→
01/17 14:38, , 1F
01/17 14:38, 1F
→
01/17 14:45, , 2F
01/17 14:45, 2F
→
01/17 18:01, , 3F
01/17 18:01, 3F
→
01/18 08:39, , 4F
01/18 08:39, 4F