JAVA: FileInputStream and FileOutputStream
fileinputstream, fileoutputstream, java
Solution
May be it works
try
{
java.net.URL url = this.getClass().getResource("/resources/SQL.properties");
java.io.FileInputStream pin = new java.io.FileInputStream(url.getFile());
java.util.Properties props = new java.util.Properties();
props.load(pin);
}
catch(Exception ex)
{
ex.printStackTrace();
}
and check the below url
getResourceAsStream() vs FileInputStream
Problem
I have this strange thing with input and output streams, whitch I just can't understand. I use inputstream to read properties file from resources like this: ``` Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream( "/resources/SQL.properties" ); rop.load(in); return prop; ``` It finds my file and reds it succesfully. I try to write modificated settings like this: ``` prop.store(new FileOutputStream( "/resources/SQL.properties" ), null); ``` And I getting strange error from storing: ``` java.io.FileNotFoundException: \resources\SQL.properties (The system cannot find the path specified) ``` So why path to properties are changed? How to fix this? I am using Netbeans on Windows