Solved "System could not find path specified"

Discussion in 'Plugin Development' started by FadedMystery, Feb 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    FadedMystery

    I was creating a file and the System could not find the path specified apparently. I set the location to: "plugins/BanAPI/bans.yml" so, I don't know. Here's the whole method.
    Code:java
    1. private static void setupBansFile() {
    2.  
    3. dataFile = new File("plugins/BanAPI/bans.yml");
    4.  
    5. if (!dataFile.exists()) {
    6.  
    7. try {
    8. System.out.println("[%s] <BanAPI> Creating the bans.yml file..".replaceAll("%s", pl.getName()));
    9. dataFile.createNewFile();
    10. System.out.println("[%s] <BanAPI> Created the bans.yml file!".replaceAll("%s", pl.getName()));
    11. }
    12.  
    13. catch (Exception e) {
    14. System.out.println("[%s] <BanAPI> Could not create the bans.yml file!".replaceAll("%s", pl.getName()));
    15. }
    16. }
    17.  
    18. dataConfig = YamlConfiguration.loadConfiguration(dataFile);
    19.  
    20. }
     
  2. Offline

    Gater12

  3. Offline

    FadedMystery

    Gater12 The thing is I want the folder in BanAPI not the plugin's folder.

    bump

    Fixed it; for those who are wondering how I fixed it I made a separate File variable for the location of the file then, mkdir()'d it.
    Example:
    Code:java
    1. File dir = new File("plugins" + File.separator + "BanAPI");
    2.  
    3. if(!dir.exists()) dir.mkdir();

    then after, with the bans.yml file, I did it like this:
    Code:java
    1. dataFile = new File(dir + File.separator + "bans.yml");

    I added "File.separator" instead of "/" because I heard for other operating systems it can cause problems.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page