Java IP Address Get getInternetIpAddress()

Here you can find the source of getInternetIpAddress()

Description

get Internet Ip Address

License

Open Source License

Declaration

public static String getInternetIpAddress() throws Exception 

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 getInternetIpAddress() throws Exception {
        URL oUrl = new URL("http://checkip.amazonaws.com");
        BufferedReader brINPUT = null;

        try {//from  www  . ja  va  2  s  .c  o  m
            brINPUT = new BufferedReader(new InputStreamReader(oUrl.openStream()));
            String strReturnIP = brINPUT.readLine();
            return strReturnIP;
        } finally {
            if (brINPUT != null) {
                try {
                    brINPUT.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. getInputStreamFromZipFile( String zipFilePath, String resourcePath)
  2. getInterfaceAddress(final String ifaceName, final boolean ipV4)
  3. getInterfaceIPs()
  4. getInternalIp()
  5. getInternalIp()
  6. getIntfFromLabelAdva(int n, Inet4Address ip)
  7. getIntranetIp()
  8. getIp()
  9. getIp()