本帖最后由 天秀lllj 于 2020-9-5 14:40 编辑
代码是if (!(new file("./Load/NewPlayer/" + p.getName() + ".yml").exists())) {
(new file("./Load/NewPlayer/" + p.getName() + ".yml").exists());
}
(帮我康康呗,大佬)
代码是if (!(new file("./Load/NewPlayer/" + p.getName() + ".yml").exists())) {
(new file("./Load/NewPlayer/" + p.getName() + ".yml").exists());
}
(帮我康康呗,大佬)
本帖最后由 洞穴夜莺 于 2020-9-5 14:41 编辑
使用File#createNewFile(),下面是该方法原文
复制代码
使用File#createNewFile(),下面是该方法原文
- /**
- * Atomically creates a new, empty file named by this abstract pathname if
- * and only if a file with this name does not yet exist. The check for the
- * existence of the file and the creation of the file if it does not exist
- * are a single operation that is atomic with respect to all other
- * filesystem activities that might affect the file.
- * <P>
- * Note: this method should <i>not</i> be used for file-locking, as
- * the resulting protocol cannot be made to work reliably. The
- * {@link java.nio.channels.FileLock FileLock}
- * facility should be used instead.
- *
- * @Return <code>true</code> if the named file does not exist and was
- * successfully created; <code>false</code> if the named file
- * already exists
- *
- * @throws IOException
- * If an I/O error occurred
- *
- * @throws SecurityException
- * If a security manager exists and its {@link
- * java.lang.SecurityManager#checkWrite(java.lang.String)}
- * method denies write access to the file
- *
- * @Since 1.2
- */
- public boolean createNewFile() throws IOException {
- SecurityManager security = System.getSecurityManager();
- if (security != null) security.checkWrite(path);
- if (isInvalid()) {
- throw new IOException("Invalid file path");
- }
- return fs.createFileExclusively(path);
- }
洞穴夜莺 发表于 2020-9-5 14:39
使用File#createNewFile(),下面是该方法原文
我一般创建config.yml的话是File file = new file("config.yml")...
天秀lllj 发表于 2020-9-5 14:41
我一般创建config.yml的话是File file = new file("config.yml")...
保存配置文件用FileConfiguration#save(File)或FileConfiguration#save(String)即可,用法自行查javadoc或注释
洞穴夜莺 发表于 2020-9-5 14:44
保存配置文件用FileConfiguration#save(File)或FileConfiguration#save(String)即可,用法自行查javadoc ...
哦哦,我去试试,谢谢大佬
感谢大佬