Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Properties - reposted
- From: S.Sureshbabu@xxxxxxx (Sureshbabu, S)
- Subject: Properties - reposted
- Date: Thu, 30 Dec 1999 01:17:44 -0500
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01BF528C.B7A3DAF2
Content-Type: text/plain
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();
}
}
------_=_NextPart_001_01BF528C.B7A3DAF2
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2651.14">
<TITLE>RE: Properties - reposted</TITLE>
</HEAD>
<BODY>
<P><FONT COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">Hi,</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">I too have observed that Properties' =
save() method doesn't work.But if you observe ,even your =
p2.list(System.out);</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> command doesn't work.Try with =
the code which I have pasted below.Properties p2 is not =
necessary.</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">If you really need to write to a =
file,you can create a printwriter object and then link to a file =
.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Regards</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Sureshbabu</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">import java.util.*;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">import java.io.*;</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">class P {</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">public static void main(String[] a) =
throws IOException {</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Properties p1=3Dnew =
Properties(System.getProperties());</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">FileOutputStream f1=3Dnew =
FileOutputStream("O.O");</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">p1.list(System.out);</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">p1.save(f1, "Here it =
goes...");</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">/*</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">public synchronized void =
save(OutputStream out, String header)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Stores this property LIST to the =
specified output stream. The string</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">header is printed as a comment at the =
beginning of the stream.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">*/</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">//Properties p2=3Dnew =
Properties();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">FileInputStream f2=3Dnew =
FileInputStream("O.O");</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">//p1.load(f2);</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">/*Enumeration e =3D =
p1.propertyNames();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">while(e.hasMoreElements())</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> =
System.out.println("The properties are "+e.nextElement()); =
</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}*/</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">//System.out.println("The =
property names are "+);</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">f1.close();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">f2.close();</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>=20
</P>
<BR>
</BODY>
</HTML>
------_=_NextPart_001_01BF528C.B7A3DAF2--
---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- Follow-Ups:
- Properties - reposted
- From: Kishan A
- Properties - reposted
- Prev by Date: EJB Reference implementation - missing classes
- Next by Date: HTMLDocument
- Previous by thread: Properties - reposted
- Next by thread: Properties - reposted
- Index(es):