I am trying to load a properties file.
I have the properties file in the same directory as the class that I am trying to load it.
Example:
package com.classes.internal;
public class ClassA {
private static String PFILE = "config.properties";
private static void methodA(){
//do stuff
Properties properties = null;
try{
properties = new Properties();
properties.load(new FileInputStream(PFILE));
//properties.load(new ClassA().getClass().getResourceAsStream(PFILE)); --> Does not work either
}catch(Exception e){
e.printStackTrace();
}
}
Also config.properties
file is in com\classes\internal dir
But I get a FileNotFoundException
or java.lang.NullPointerException
(if using the commented out line instead of the first)
What am I doing wrong here? What am I missunderstanding?