复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14file.isDirectory() 来判断这是不是一个文件夹。 if (file.exists()) { 来判断这是不是一个文件。 1.File testFile = new File(testFilePath); if(!file.isDirectory()) { testFile.mkdirs(); System.out.println("测试文件夹不存在"); } 2.File testFile = new File(testFilePath); if(!testFile .exists()) { testFile.createNewFile(); System.out.println("测试文件不存在"); }
最后
以上就是无私冬天最近收集整理的关于java判断给定路径或URL下的文件或文件夹是否存在?的全部内容,更多相关java判断给定路径或URL下内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复