struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Chacón Sánchez" <danielc...@gmail.com>
Subject Re: OutputStreamPath
Date Thu, 01 Mar 2007 20:59:41 GMT
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@gmail.com>:
>
> 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!!
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message