How to load files from folder in plugins folder?

Discussion in 'Plugin Development' started by pj6444, Mar 24, 2014.

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


    Hi all,

    I am making a plugin and I want to have some files for my plugin outside of the actual jar itself. Does anyone know how I can load in files that are in the same folder as my jar and use them?

  2. Offline


    huh ? explain a bit more xD
  3. Offline


    Ok. So I have a separate folder inside my plugins folder and I want to be able to access the files in there through the jar. But I need to find the path relative to the jar file and not hard code the actual path.
  4. Offline


    why don't you add it as a build path -_- xD
  5. Offline


    Check out the Java io API. Not a bukkit related question.
  6. Offline


    The path to your plugin folder (/MyPluginName/) inside craftbukkit directory is provided by getDataFolder() from the JavaPlugin class. According to java files api, you can get the parent folder with file.getParent(), that would get the /plugins/ folder, where your jar is stored
  7. Offline


    pj6444 Assuming these files are not config files, place the files inside of your eclipse project folder.. And use saveResource method provided by Bukkit API to copy the files from inside the jar to your plugin directory, saveResource will require the file name with the extension and a boolean to replace the files or not.
  8. Offline


    Thanks everyone! You've helped me a lot!
Thread Status:
Not open for further replies.

Share This Page