JeeStudy 发表于 2016-11-13 21:04:48

JAVA 调用delete()方法删除文件失败


JAVA 调用delete()方法删除文件失败


File file = new File(Thread.currentThread().getContextClassLoader().getResource("").getPath() + "/init");
FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.close();
file.delete();


在调用删除方法(file.delete();)之前一定先把流关闭(fileInputStream.close();),否则删除失败

页: [1]
查看完整版本: JAVA 调用delete()方法删除文件失败