Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

properties file

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im trying to read in a properties file, this werks like this:
Properties pr = new Properties();
File fname = new File("/tmp/deprop.properties");
FileInputStream input_stream = new FileInputStream(fname);
pr.load(input_stream);
String Name = pr.getProperty("Name");
now i wanna built a loop to readin all existing record and automatically built the strings out of it , like
properties file: name = eric jsp-page: string name = pr.getprop("name"), etc some1 could help me plz?
what i need to know,2 how do i write a properties file, is it the same way then reading it? thx
eric
[This message has been edited by eric clark (edited January 19, 2001).]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since java.util.Properties is based on java.util.Hashtable, you can get an enumeration over all of the property names with:
Enumeration e = myProp.keys();
// or the easy to remember:
Enumeration e = myProp.propertyNames() ;
A Properties can list to a PrintStream like this:
myProp.list( System.out ) ; // a nice readable format
You can also save a Properites object to a file
with the store() method
A good reference such as Java in a Nutshell and/or copy of the JavaDocs is your friend.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic