Guest User

Untitled

a guest
Jan 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.net.InetAddress;
  3. import java.util.*;
  4.  
  5. public class HostInfo {
  6.  
  7. public static void main(String[] args) throws Exception {
  8. String regex = "^(java\\.version)|(os\\.name)$";
  9. if (args.length > 0) {
  10. regex = args[0];
  11. }
  12. List<String> keys = new ArrayList<>(System.getProperties().stringPropertyNames());
  13. Collections.sort(keys);
  14. for (String key : keys) {
  15. if (key.matches(regex)) {
  16. System.out.format("%s=%s%n", key, System.getProperty(key));
  17. }
  18. }
  19. InetAddress address = InetAddress.getLocalHost();
  20. System.out.format("InetAddress.getLocalHost() = %s%n", address);
  21. }
  22.  
  23. }
Add Comment
Please, Sign In to add comment