Java IP Address Get getIPAddress()

Here you can find the source of getIPAddress()

Description

get IP Address

License

Open Source License

Declaration

private static String getIPAddress() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.InputStreamReader;
import java.net.URL;

public class Main {
    private static String getIPAddress() {
        String ipAddress = "";
        try {//from  ww  w  .ja va 2  s .c o  m
            URL whatismyip = new URL("http://icanhazip.com");
            BufferedReader in = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
            ipAddress = in.readLine();
            System.out.println(ipAddress);
        } catch (Exception e) {
            // TODO log4j
        }
        return ipAddress;
    }
}

Related

  1. getIpAddress()
  2. getIpAddress()
  3. getIpAddress()
  4. getIpAddress()
  5. getIPAddress()
  6. getIPAddress()
  7. getIpAddress()
  8. getIpAddress()
  9. getIPAddress()