private static String getMyIP() throws IOException {
InputStream ins = null;
try {
String l = "http://1212.ip138.com/ic.asp";
URL url = new URL(l);
URLConnection con = url.openConnection();
ins = con.getInputStream();
InputStreamReader isReader = new InputStreamReader(ins, "gb2312");
BufferedReader bReader = new BufferedReader(isReader);
StringBuffer webContent = new StringBuffer();
String str = null;
while ((str = bReader.readLine()) != null) {
webContent.append(str);
}
System.out.println(webContent);
int start = webContent.indexOf("[") + 1;
int end = webContent.indexOf("]");
return webContent.substring(start, end);
} finally {
if (ins != null) {
ins.close();
}
}
}