In my current application, I need to support one config.properties , and from this properties file I need to get the data in my java file. I put the properties file and ConfigUtil.java , which accesses these properties files, is in one place. But when I launch the application, it gives a FileNotFoundException .
I cannot understand why this does not load the properties file if both are inside the same folder.
My ConfigUtils.java code:
public class ConfigUtil { private Properties properties; InputStream inputStream = null; public Properties getUrl(){ properties = new Properties(); try { inputStream = new FileInputStream("config.properties"); properties.load(inputStream); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { if(inputStream != null){ try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return properties; } }
and the config.properties file is also located in the same folder as config.properties :
/app/src/main/java/config.properties
ConfigUtil.java location:
/app/src/main/java.configutils.java
anand source share