
{filelink=23}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package publicationpro;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
/**
*
* @author Administrateur Sako Adams
*/
public class NativeIP {
public static String getIP() throws Exception {
URL whatismyip = new URL("http://checkip.amazonaws.com");
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(
whatismyip.openStream()));
String ip = in.readLine();
return ip;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void main(String...args) throws Exception
{
System.out.println(getIP());
}
}