有什么方法能实现只判断文件是否存在而不创建新的文件

本帖最后由 Lss233 于 2018-6-29 12:25 编辑
复制代码
如果你要检测的文件在插件文件夹里,第一行可以用
复制代码
(注: this.getDataFolder() 是 JavaPlugin 类中的方法)
- File file = new File("文件名");
- if(file.exists()){
- // 文件存在
- } else {
- //文件不存在
- }
如果你要检测的文件在插件文件夹里,第一行可以用
- File file = new File(this.getDataFolder(), "文件名");
(注: this.getDataFolder() 是 JavaPlugin 类中的方法)