1 |
package tools; |
2 |
|
3 |
import java.net.*; |
4 |
import java.util.Properties; |
5 |
|
6 |
public class Machine { |
7 |
|
8 |
public static String getClient() { |
9 |
String client = ""; |
10 |
try { |
11 |
client = InetAddress.getLocalHost().getHostName(); |
12 |
} catch (Exception e) { |
13 |
System.err.println(e); |
14 |
} |
15 |
return client; |
16 |
} |
17 |
public static String getOSArch() { |
18 |
return (System.getProperty("os.arch")); |
19 |
} |
20 |
|
21 |
public static String getOSName() { |
22 |
return (System.getProperty("os.name")); |
23 |
} |
24 |
|
25 |
public static String getOSver() { |
26 |
return (System.getProperty("os.version")); |
27 |
} |
28 |
|
29 |
public static String getUserName() { |
30 |
return (System.getProperty("user.name")); |
31 |
} |
32 |
|
33 |
public static String getTempDir() { |
34 |
return(System.getProperty("java.io.tmpdir")); |
35 |
} |
36 |
|
37 |
public static Properties getAllProperties() { |
38 |
return System.getProperties(); |
39 |
} |
40 |
|
41 |
public static long getTotalMemory() { |
42 |
return Runtime.getRuntime().totalMemory(); |
43 |
} |
44 |
|
45 |
public static long getFreeMemory() { |
46 |
return Runtime.getRuntime().freeMemory(); |
47 |
} |
48 |
|
49 |
public static void main(String[] args) { |
50 |
System.out.println("Hi, I am " + getClient() + " and these are my properties:"); |
51 |
getAllProperties().list(System.out); |
52 |
System.out.printf("Total memory: %,d bytes\n", getTotalMemory()); |
53 |
System.out.printf("Free memory : %,d bytes\n", getFreeMemory()); |
54 |
} |
55 |
} |
56 |
|