I'm loading a prop and saving it
File propfile=new File(getClass().getResource("credentials.properties").toURI());
prop.load(new FileInputStream(propfile));
prop.setProperty("a", username);
prop.setProperty("c", password);
prop.setProperty("b", pbKey);
prop.store(new FileOutputStream(propfile), null);
When i normally run this in netbeans its fine, when its bundled into .jar file it throws
Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
at java.io.File.(Unknown Source)
now when i use
getClass().getResourceAsStream("credentials.properties");
i can read the file , but i can't save the file unless i use the .toURI()
as in -> Storing changes in .properties file that has been read via getClass().getResourceAsStream
so when i use toURI() and when i run it (jar file) it would cry out saying the URI is not hierarchical
and when i use getResourceAsStream
, i couldn't save the file
what should i do? the properties file is in same package as class is in.