I need the application to show me my current ip address.
In this case, we have something like this (Get request)
I need to get ip from here
public class Main {
public static void main(String[] args) throws Exception {
String url = "http://2ip.ru/";
URL obj = new URL(url);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
}
}