JEE Study|JAVA EE|企业级开发学习网

标题: JAVA 调用delete()方法删除文件失败 [打印本页]

作者: JeeStudy    时间: 2016-11-13 21:04
标题: JAVA 调用delete()方法删除文件失败

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


[Java] 纯文本查看 复制代码
File file = new File(Thread.currentThread().getContextClassLoader().getResource("").getPath() + "/init");
FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.close();
file.delete();



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






欢迎光临 JEE Study|JAVA EE|企业级开发学习网 (http://jeestudy.com/) Powered by Discuz! X3.2