Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.*;
- public class getIP {
- public static void main(String args[]) throws Exception {
- InetAddress host = null;
- host = InetAddress.getLocalHost();
- byte ip[] = host.getAddress();
- for (int i=0; i<ip.length; i++) {
- if (i > 0) {
- System.out.print(".");
- }
- System.out.print(ip[i] & 0xff);
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement