Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Properties - reposted


  • From: kishan.a@xxxxxxxxxxxxxxxx (Kishan A)
  • Subject: Properties - reposted
  • Date: Thu, 30 Dec 1999 12:38:46 +0530

Hi,

Dont create the Properties by passing System.getProperties to the
constructor.
The documentation clearly says that this is only used as defaults. Defaults
in the sense, this property will be looked into only if the requested key is
not there in your properties. The default properties is in no way part of
your properties and hence is not written to the file when u save.
Instead of using
Properties p1=new Properties(System.getProperties());
use
Properties p1=System.getProperties()
It will work.
There is no problems with save() or list() methods.

Regards,
Kishan

PS: Note that save() is deprecated in 1.2 and store() is provided in place
of it.



-----Original Message-----
From: Sureshbabu, S [mailto:S.Sureshbabu@xxxxxxx]
Sent: Thursday, December 30, 1999 11:48 AM
To: 'esse@xxxxxxxxxxx'; advanced-java@xxxxxxxxxxxxxxxx
Subject: RE: Properties - reposted


Hi,
I too have observed that Properties' save() method doesn't work.But if you
observe ,even your p2.list(System.out);
 command doesn't work.Try with the code which I have pasted below.Properties
p2 is not necessary.


If you really need to write to a file,you can create a printwriter object
and then link to a file .
Regards
Sureshbabu


import java.util.*;
import java.io.*;
class P

public static void main(String[] a) throws IOException

Properties p1=new Properties(System.getProperties());
FileOutputStream f1=new FileOutputStream("O.O");
p1.list(System.out);
p1.save(f1, "Here it goes...");
/*
public synchronized void save(OutputStream out, String header)
Stores this property LIST to the specified output stream. The string
header is printed as a comment at the beginning of the stream.
*/
//Properties p2=new Properties();
FileInputStream f2=new FileInputStream("O.O");
//p1.load(f2);
/*Enumeration e = p1.propertyNames();
while(e.hasMoreElements())
{ 
         System.out.println("The properties are "+e.nextElement()); 
}*/ 
  
//System.out.println("The property names are "+); 
f1.close(); 
f2.close(); 
} 
} 


---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx