Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4916

Re: Properties file ?

From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
Newsgroups comp.lang.java.gui
Subject Re: Properties file ?
References <657850d3-2af5-4c99-9677-e18b3ad91bf6@q8g2000yqa.googlegroups.com>
Message-ID <7n5Pq.1608$nn3.361@newsfe16.iad> (permalink)
Date 2012-01-10 17:13 -0800

Show all headers | View raw


On 1/10/12 1:36 PM, The Nigga wrote:
> I am trying create a properties file and save in a package of my
> project, I can read but I can not save. The package name is
> "properties".
>
> I am trying this.
>
>
> Properties p = new Properties();
> //reading, work.
> p.load(getClass().getClassLoader().getResourceAsStream("properties/
> file.properties"));
> System.out.println(p.getProperty("myKey"));
>
> //saving, not work
> p.store(getClass().getClassLoader().getResourceAsStream("properties/
> file.properties"),"Config File");
>
> How to save my file.properties in package "properties" ?
>
> thanks.
Hint, you don't want to store it in your classpath. 
getResourceAsStream() returns an InputStream, so you can only read, not 
write it.

Instead of putting it in a "package", put it in a good location, perhaps 
using the one in the package as a default, but allowing saving it 
elsewhere.

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Properties file ? The Nigga <fernandopaivabr@gmail.com> - 2012-01-10 13:36 -0800
  Re: Properties file ? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-01-10 17:13 -0800
    Re: Properties file ? The Nigga <fernandopaivabr@gmail.com> - 2012-01-10 18:09 -0800
      Re: Properties file ? "John B. Matthews" <nospam@nospam.invalid> - 2012-01-10 21:24 -0500
        Re: Properties file ? The Nigga <fernandopaivabr@gmail.com> - 2012-01-10 19:31 -0800
          Re: Properties file ? The Nigga <fernandopaivabr@gmail.com> - 2012-01-11 02:08 -0800
          Re: Properties file ? "John B. Matthews" <nospam@nospam.invalid> - 2012-01-11 08:13 -0500

csiph-web