I would like to save YML files in Minecraft with Spigot which always have the player name as the file name and then .yml. In the code it would have looked like this:
File file = new file ("plugins / SpyPlugin", event.getPlayer (). GetName () + ".yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration (file);
But whenever the file is to be saved in the code, the console says that it can't save the file because the file name is incorrect.
So how else should I do that?
With
new file (path);
you don't save the file. You just create a reference in your code and
YamlConfiguration.loadConfiguration (file);
of course throws the error because the file doesn't exist yet.
In between you still have to
file.createNewFile ()
call to really write the file