Solved EOFException when reading config

Discussion in 'Spigot Plugin Development' started by Gypopo, Mar 19, 2020.

  1. Heyo Spigot,

    I got an error while trying to read my config file, it appeard today while testing the plugin. Yesterday the code was running fine on my other plugin.

    This is the full error I get: https://pastebin.com/zuN9MUmT
    The error leads to:
    Code (Java):
    InputStream customClassStream = EconomyShopGUI.getInstance().getClass().getResourceAsStream("/config.yml");
                    InputStreamReader strR = new InputStreamReader(customClassStream);
                    FileConfiguration defaults = YamlConfiguration.loadConfiguration(strR);
    If I try to run this:
    Code (Java):
    InputStream customClassStream = EconomyShopGUI.getInstance().getClass().getResourceAsStream("/config.yml");
                    BufferedReader strR = new BufferedReader(new InputStreamReader(customClassStream));
                    FileConfiguration defaults = YamlConfiguration.loadConfiguration(strR);
    Then the error leads again to the same code. Error: https://pastebin.com/ZbgEsnwr


    I already searched on google for why it happens, I found this: https://docs.oracle.com/javase/7/docs/api/java/io/EOFException.html
    So I assume this error is happening becausse the jar file is corrupt.
    But the question is, how can I fix this?

    Or do I miss something here?

    Thanks
     
  2. just do JavaPlugin#loadResource or whatever the method is to get the input stream and do what you want with it
     
  3. Spigot has own getResource() in JavaPlugin
    Code (Java):

    FileConfiguration defaults = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(plugin.getResource("config.yml"))));
     
     
  4. I literally sent you a thread about that...
     
  5. Oh, ok.
    Thanks, marked as solved.