Solved Saying file does not exist when it does...

Discussion in 'Plugin Development' started by SleepyDog, Oct 20, 2014.

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

    SleepyDog

    This is the code i am running:
    Code:java
    1. File file = new File(getDataFolder() + "DevFolder.yml");
    2. FileConfiguration fc = YamlConfiguration.loadConfiguration(file);
    3. String version = "";
    4. String message = "";
    5. String message2 = "";
    6. if(file.exists()){
    7. version = fc.getString("currentVersion");
    8. message = fc.getString("newVersionMessage");
    9. message2 = fc.getString("upToDateMessage");
    10. if (version.equals("1.0")){
    11. getLogger().info(message);
    12. }
    13. else {
    14. getLogger().info(message2);
    15. }
    16. }
    17. else{
    18. getLogger().info("=============ERROR=============");
    19. getLogger().info("WARNING: 'plugins/clearchat/DevFolder.yml' CANNOT BE FOUND!");
    20. getLogger().info("WARNING: ATTEMPTING TO DOWNLOAD FILE!");
    21. try {
    22. URL website = new URL("[url]https://www.dropbox.com/s/8haw1eivk46759u/ClearChat.txt?dl=1[/url]");
    23. ReadableByteChannel rbc = Channels.newChannel(website.openStream());
    24. @SuppressWarnings("resource")
    25. FileOutputStream fos = new FileOutputStream(new File(this.getDataFolder(),"DevFolder.yml"));
    26. fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
    27. } catch(Exception ex) {
    28. ex.printStackTrace();
    29. }
    30. getLogger().info("DO '/cc' INGAME TO CHECK FOR UPDATES");
    31. getLogger().info("=============ERROR=============");
    32.  
    33. }

    On the file exits:
    [​IMG]
    it is running the else statement, even though it does exist:
    [​IMG]
    Can you help me find the issue? How would i fix this?
     
  2. Offline

    Luke_Lax

    I know this is solved but for anyone in the distant future who may come across this thread, the quickest and easiest way to solve this is to simply print or broadcast a debug message containing the variable, to see what it thinks it is. If that's not it then place debug statements (prints/broadcasts) before all of your condition checks and perhaps variable and see what fires and what's wrong :)
     
    FerusGrim likes this.
Thread Status:
Not open for further replies.

Share This Page