Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1.     public static String getAddress() {
  2.         String address = "";
  3.         try {
  4.             Socket socket = new Socket();
  5.             socket.connect(new InetSocketAddress("google.com", 80));
  6.             address = socket.getLocalAddress().getHostAddress();
  7.             socket.close();
  8.         }
  9.         catch(Exception e){
  10.             System.out.println("Failed to get local address");
  11.         }
  12.         return address;
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement