Config File Problems?

Discussion in 'Plugin Development' started by SantaClawz69, Sep 9, 2014.

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

    SantaClawz69

    Hi, it's me again. I'm not sure why but I get the most simplest problems but always find a difficulty in trying to fix them. Now this method is to create/generate a config file that is called "RESET.FILE". Now this is the code that I'm getting and it says "The method exists() is undefined" and same for createNewFile(). Does anyone know why? I've used this method more than once and only now it's not working. If someone can kindly find out why I'd be so content. Thanks guys!

    Code:java
    1. public void setupConfig() {
    2. File resetFile = new File("RESET.FILE");
    3. if (resetFile.exists()) {
    4. return;
    5. getConfig().set("Kits.MystianOffence.Items", Arrays.asList("272", "297:5"));
    6. getConfig().set("Kit.MystianOffence.Display.Item", 272);
    7.  
    8. saveConfig();
    9.  
    10. try {
    11. resetFile.createNewFile();
    12. } catch (Exception e) {
    13. e.printStackTrace();
    14. }
    15. }
    16. }
    17. }
     
  2. Offline

    Gerov

    Are you trying to make a folder? If so, use the .mkDir(); method.
     
  3. Offline

    teej107

    .mkDirs(); Big difference between those two methods.
    SantaClawz69 Btw the code you posted only creates a File object. Your return; statement is preventing the rest of the code to be executed. I also noticed that your code is missing a bracket. Could you paste the code correctly?
     
  4. Offline

    BeastCraft3

    Hellau there santa, I might know how to fix this for you .
    Code:java
    1. public void setupConfig() {
    2. File resetFile = new File("RESET.FILE");
    3. if (resetFile.exists()) {
    4.  
    5. getConfig().set("Kits.MystianOffence.Items", Arrays.asList("272", "297:5"));
    6. getConfig().set("Kit.MystianOffence.Display.Item", 272);
    7.  
    8. saveConfig();
    9.  
    10. try {
    11. resetFile.createNewFile();
    12. } catch (Exception e) {
    13. e.printStackTrace();
    14. }
    15. }
    16. }
    17. }
     
  5. Offline

    SantaClawz69

    Here I removed the return statement, yet the exists() and createNewFile() are still giving me the same error. This is weird. Do any of you think this could be because of me jre version? I'm on JRE version 8 should I put it back to JRE 6?
    teej107 I don't see any missing brackets in my code if you can point it out that'll be great. And BeastCraft3 I have the exact same thing you got still making the errors.
     
  6. Offline

    teej107

    SantaClawz69 Are you talking about the version on your computer or the version you are compiling with? Either way it shouldn't matter (for error's sake. You should compile with Java 6 for compatibility ). Make sure you are using the right imports. java.io.File
     
  7. Offline

    SantaClawz69

    I mean when I Compile it. I'm using JRE 8 currently, do you think it'll make a difference?
     
  8. Offline

    teej107

    What's the problem exactly? Is is at runtime or on your IDE?
     
  9. Offline

    SantaClawz69

    Sadly I'm using the latest version of eclipse and so I'm not able to use JRE 6 for my projects.

    teej107 there isn't any problems with the JRE itself. I'm just thinking that the JRE 8 might be causing this error, because when I was using JRE 6 nothing like this ever happened.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  10. Offline

    teej107

    Did you?
     
Thread Status:
Not open for further replies.

Share This Page