To load a properties file from classpath, we can simply do:
InputStream inputStream = CommonUtils.class.getClassLoader().getResourceAsStream("com/abc/resources/config.properties");
prop.load(inputStream);
After above step, all properties are correctly loaded. But how can I change a property and save it back to the same file on the fly? (Below doesn't work)
OutputStream outputStream = new FileOutputStream("com/abc/resources/config.properties");
prop.setProperty(key, value);
prop.store(outputStream, null);