Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.net.InetAddress;
- import java.util.*;
- public class HostInfo {
- public static void main(String[] args) throws Exception {
- String regex = "^(java\\.version)|(os\\.name)$";
- if (args.length > 0) {
- regex = args[0];
- }
- List<String> keys = new ArrayList<>(System.getProperties().stringPropertyNames());
- Collections.sort(keys);
- for (String key : keys) {
- if (key.matches(regex)) {
- System.out.format("%s=%s%n", key, System.getProperty(key));
- }
- }
- InetAddress address = InetAddress.getLocalHost();
- System.out.format("InetAddress.getLocalHost() = %s%n", address);
- }
- }
Add Comment
Please, Sign In to add comment