NullPointerException from getKeys() method

Discussion in 'Plugin Development' started by puyttre, May 4, 2013.

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

    puyttre

    Hi,

    I'm trying to read a YAML file by getting all of the keys and putting them into a HashMap. Right now I'm getting a NullPointerException at line 2.
    Code:java
    1. if (new File(getDataFolder(), "data.yml").exists()) {
    2. for (String key : data.getKeys(true)) {
    3. playerVotes.put(key, data.getInt(key));
    4. }
    5. }

    I am assuming this is from the data.getKeys(true) part. How can I fix this so that it doesn't give me an NPE?

    Thanks.
     
  2. Offline

    CubieX

    Can you show us where you initialize "data"?
    Your FileConfiguration seems not to be loaded or assigned properly.
     
Thread Status:
Not open for further replies.

Share This Page