Mercurial > hg > jslab
comparison examples/util/DumpProperties.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 package eg.util; | |
2 | |
3 import java.util.Properties; | |
4 import java.util.Enumeration; | |
5 | |
6 import java.net.InetAddress; | |
7 | |
8 public class DumpProperties | |
9 { | |
10 public static void main(String[] args) | |
11 { | |
12 Properties props = System.getProperties(); | |
13 Enumeration enum = props.propertyNames(); | |
14 | |
15 System.out.println("System Properties"); | |
16 while( enum.hasMoreElements() ) | |
17 { | |
18 String key = (String)enum.nextElement(); | |
19 String value = props.getProperty(key); | |
20 System.out.println(key + "\t" + value); | |
21 } | |
22 | |
23 try | |
24 { | |
25 InetAddress host = InetAddress.getLocalHost(); | |
26 String name = host.getHostName(); | |
27 String addr = host.getHostAddress(); | |
28 | |
29 System.out.println("hostname = " + name); | |
30 System.out.println("address = " + addr); | |
31 } | |
32 catch ( Exception e ) | |
33 { | |
34 System.err.println("Exception looking up local host name"); | |
35 e.printStackTrace(); | |
36 } | |
37 } | |
38 } |