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


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

Re: Properties file ?

From The Nigga <fernandopaivabr@gmail.com>
Newsgroups comp.lang.java.gui
Subject Re: Properties file ?
Date 2012-01-10 18:09 -0800
Organization http://groups.google.com
Message-ID <9d525b48-8a9a-450b-ae24-398cdaa985f5@f11g2000yql.googlegroups.com> (permalink)
References <657850d3-2af5-4c99-9677-e18b3ad91bf6@q8g2000yqa.googlegroups.com> <7n5Pq.1608$nn3.361@newsfe16.iad>

Show all headers | View raw


On 10 jan, 23:13, Daniel Pitts <newsgroup.nos...@virtualinfinity.net>
wrote:
> 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.

All right. I go save this file in user folder.

thanks.

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