I tried to read a .properties file and have code as following:
public final class Config {
static {
Properties properties = new Properties();
InputStream propertiesStream = Object.class.getResourceAsStream("config.properties");
if (propertiesStream != null) {
try {
properties.load(propertiesStream);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("file not found");
}
}
}
but it keeps saying file not found.
The content of properties is
pwd=passw0rd
Anyone knows how to solve this problem?
It should be in classpath, put it to your root source package, if its a maven project put it to src/main/resources
directory