/**
* 获取外网地址
*@engineer wangrun
*@Description
* time 2013-1-29 下午01:34:03
* @return void
*/
public static void getPublicIP(){
String inputLine = "";
String read = "";
String ip = "";
try {
URL url = new URL("http://checkip.dyndns.org/");
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
urlConnection.getInputStream()));
while ((read = in.readLine()) != null) {
inputLine += read;
}
System.out.println(inputLine);
String[] strs = inputLine.split(":");
ip = strs[1].split("<")[0];
System.out.println(ip);
} catch (Exception e) {
e.printStackTrace();
}
}
* 获取外网地址
*@engineer wangrun
*@Description
* time 2013-1-29 下午01:34:03
* @return void
*/
public static void getPublicIP(){
String inputLine = "";
String read = "";
String ip = "";
try {
URL url = new URL("http://checkip.dyndns.org/");
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
urlConnection.getInputStream()));
while ((read = in.readLine()) != null) {
inputLine += read;
}
System.out.println(inputLine);
String[] strs = inputLine.split(":");
ip = strs[1].split("<")[0];
System.out.println(ip);
} catch (Exception e) {
e.printStackTrace();
}
}