Solved Help

Discussion in 'Plugin Development' started by OfficerDeveloper, Mar 29, 2015.

Thread Status:
Not open for further replies.
  1. Hello! I am trying to delete a file, more specifically a YamlConfiguration file, and the code I have, I do not know if it will delete the specific FILE or the whole FOLDER. I need a meathod that like, deletes the config file.
            public static void deleteArena(String name, Player user) throws IOException {
                File f = new File("plugins/KOTH/arenas/", name + ".yml");
                YamlConfiguration fl = YamlConfiguration.loadConfiguration(f);
                if (!f.exists()) {
                    sendMessage(user, "&cAn arena doesn't exist with that name!");
                } else {
                    sendMessage(user, "You have succesfully removed an arena with the name: &c" + name);
  2. Offline


    try and catch f#delete();
  3. it throws an IOException, so no need.
  4. Offline


  5. Offline


    @OfficerDeveloper f.delete(); will delete one file, so if you specify that file (e.g. /arenas/name.yml), then that one file will be deleted. If you specify the folder (e.g. /arenas/), it and all it's contents will be deleted.
  6. Ty :)
  7. Offline


Thread Status:
Not open for further replies.

Share This Page