zhengbn

windows下使用java.io.File.delete()方法删除文件时,返回值为true

但是本地文件仍然存在,也就是说没有删除成功。

这时候你要检查下你传进来的文件目录格式是否正确。

  • 正确:d://dir//111.jpg
  • 错误:d:\dir\111.jpg
File f = new File("d://dir//111.jpg");
if (f.exists()) {
    System.err.println("文件存在");
    boolean t = f.delete();
}else{
    System.err.println("不存在");
}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-12-08
  • 2022-02-13
  • 2021-12-12
  • 2022-12-23
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
相关资源
相似解决方案