You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
824 B
25 lines
824 B
package com.example;
|
|
import java.io.BufferedReader;
|
|
import java.io.InputStreamReader;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
|
|
public class ProxyIPChecker {
|
|
public static void main(String[] args) throws Exception {
|
|
URL url = new URL("http://httpbin.org/ip");
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("GET");
|
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
|
String inputLine;
|
|
StringBuilder response = new StringBuilder();
|
|
|
|
while ((inputLine = in.readLine()) != null) {
|
|
response.append(inputLine);
|
|
}
|
|
in.close();
|
|
|
|
System.out.println("当前公网 IP 信息:");
|
|
System.out.println(response.toString());
|
|
}
|
|
}
|