Got it:
String path= Thread.currentThread().getContextClassLoader().
getResource(pathToConfigurationFile).getPath();
OutputStream out = new FileOutputStream(path);
properties.store(out, "");
2007/3/1, Daniel Chacón Sánchez <danielccss@(protected)>:
>
> Someone?
>
> Hi all
>
> I have a question, how I can set the path for the OutputStream like i get
> it for the InputStream with getResourceAsStream?
>
> This is my code:
>
>
> Properties properties = new Properties();
> String pathToConfigurationFile =
> "common/properties/Configuracion.properties";
> InputStream input =
> Thread.currentThread().getContextClassLoader().getResourceAsStream(
> pathToConfigurationFile);
>
> //Load the properties
> properties.load(input);
> input.close ();
>
> //Set the property datasource
> properties.setProperty("datasource", datasource);
>
> //Now I want to save the changes to the properties file
>
> OutputStream out= new FileOutputStream(
> pathToConfigurationFile);
> properties.store(out, "");
>
> //But an exception occurs and it tells me that the
> "common/properties/Configuracion.properties" was not found.
>
> How I can get the correct path for the outputStream like i did with the
> inputStream
>
> Thanks!!
>