Java IP Address Get getPublicIP()

Here you can find the source of getPublicIP()

Description

get Public IP

License

Open Source License

Declaration

public static String getPublicIP() 

Method Source Code


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

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

public class Main {
    public static String getPublicIP() {
        try {/*from w  w w  .jav  a  2 s.  c  om*/
            URL awsCheckIpUrl = new URL("http://checkip.amazonaws.com");
            BufferedReader br = new BufferedReader(new InputStreamReader(awsCheckIpUrl.openStream()));
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. getLocalV4IpList()
  2. getLongIp(byte[] buff)
  3. getLongIp(String ipString)
  4. getPublicIP()
  5. getPublicIP()
  6. getPublicIP()
  7. getPublicIP()
  8. getPublicIP()
  9. getPublicIP2()