I need to read the configuration file. I get this error when running the following code:
java.util.Properties$LineReader.readLine
The config.cfg file is present and has r / w permissions.
import java.util.*; import java.util.Properties; public class Config { Properties configFile; public Config() { configFile = new java.util.Properties(); try { configFile.load(this.getClass().getClassLoader(). getResourceAsStream("config.cfg")); }catch(Exception eta){ eta.printStackTrace(); } } public String getProperty(String key) { String value = this.configFile.getProperty(key); return value; } }
EDIT - Complete Error
[java] java.lang.NullPointerException [java] at java.util.Properties$LineReader.readLine(Properties.java:418) [java] at java.util.Properties.load0(Properties.java:337) [java] at java.util.Properties.load(Properties.java:325) [java] at Config.<init>(Unknown Source) [java] at ClosureBuilder.<clinit>(Unknown Source)
EDIT - Directory Structure
Src
-> config.java
-> config.cfg
source share