This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Java in General and the fly likes Property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Property" Watch "Property" New topic


aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
Could I have an example of how to use java.util.Property
Is it the same used for storing an environment variable.

My Queries:
1) Say i had stored my key-value values in file
Now in my code how do i read the values from the files

2) Can i add some values dynamically from code to the

3) Could I get the values of from System.getProperty() or could i load the project.proerties from System.getProperty()

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13027
If you will look at the JavaDocs for java.util.Properties, you will see that it has the load( InputStream ), store( OutputStream ) and setProperty( key, value) methods. These take care of 1) and 2)
You should not be trying to use the System properties for your specific application. Use a separate properties file.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by aakash bhatt:
Is it the same used for storing an environment variable.

As far as I know, Java does not support OS environment variables, except via a deprecated method on java.lang.System. It has been deprecated since an early version and may not do anything at all now. Certainly, you should not use it.

You can use platform-specific code to get/set OS environment variables, with JNI.

Anyone know why OS environment variables are unsupported by Java? What platform didn't like them? The concept exists in all DOS/Windows/Unix/Linux/MacOSX.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: Property
It's not a secret anymore!