KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > TestProps


1 // TestProps.java
2

3 import java.io.*;
4 import java.util.*;
5
6 public class TestProps {
7
8     public static void main(String JavaDoc args[])
9     {
10     try {
11
12         String JavaDoc p = System.getProperty("os.version"); // get one property
13
System.out.println("os.version="+p);
14
15         ByteArrayOutputStream bos = new ByteArrayOutputStream();
16         Properties P = new Properties(System.getProperties());
17         System.getProperties().save(bos,"basic props");
18         DataOutputStream ds = new DataOutputStream(bos);
19         ds.writeBytes("awt.image.incrementaldraw=true\n");
20         ds.writeBytes("awt.image.redrawrate=50\n");
21         ds.close();
22
23         byte[] tmp = bos.toByteArray();
24         ByteArrayInputStream bis = new ByteArrayInputStream(tmp);
25         P.load(bis);
26         System.setProperties(P);
27         System.getProperties().list(System.out); // list all properties
28

29     } catch (Exception JavaDoc e) {
30         e.printStackTrace();
31     }
32     }
33 }
34
35 // fini
36
Popular Tags