Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. import java.net.*;
  2. public class getIP {
  3.    public static void main(String args[]) throws Exception {
  4.      InetAddress host = null;
  5.      host = InetAddress.getLocalHost();
  6.      byte ip[] = host.getAddress();
  7.      for (int i=0; i<ip.length; i++) {
  8.        if (i > 0) {
  9.        System.out.print(".");
  10.        }
  11.        System.out.print(ip[i] & 0xff);
  12.      }
  13.    System.out.println();
  14.    }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement