我的环境是JBuilder+Tomcat。其实是我在上传文件后(保存到了某个目录),但同时在Tomcat目录也会生成一个(例如:3614dbcbe8b5750a36be2821544e49afzhangy.txt)相同内容的文件。现在我在删除这个文件的时候,死活都删不掉。部分源码如下:
File upFile = getUpLoadFile("UploadFile"); //写输入文件
byte fileByte[] = new byte[Integer.parseInt(Long.toString(upFile.length()))];
try { FileInputStream ddd = new FileInputStream(upFile); ddd.read(fileByte);
ddd.close(); FileOutputStream outf = new FileOutputStream(new File(outFilename));
outf.write(fileByte);
outf.close();
upFile.delete();
File upFile = getUpLoadFile("UploadFile"); //写输入文件
byte fileByte[] = new byte[Integer.parseInt(Long.toString(upFile.length()))];
try { FileInputStream ddd = new FileInputStream(upFile); ddd.read(fileByte);
ddd.close(); FileOutputStream outf = new FileOutputStream(new File(outFilename));
outf.write(fileByte);
outf.close();
upFile.delete();
并且我用canWrite()测试是可写的状态。
我上面的outf.close();不是?