Skip to content

Instantly share code, notes, and snippets.

@chulkilee
Created March 31, 2015 17:36
Show Gist options
  • Save chulkilee/4784f6996d1ee0316622 to your computer and use it in GitHub Desktop.
Save chulkilee/4784f6996d1ee0316622 to your computer and use it in GitHub Desktop.
Print public ip address from Ipify
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
public class Ipify {
public static void main(String[] args) throws Exception {
URL url = new URL("http://api.ipify.org");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
for (String line; (line = reader.readLine()) != null;) {
System.out.println(line);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment