Created
March 31, 2015 17:36
-
-
Save chulkilee/4784f6996d1ee0316622 to your computer and use it in GitHub Desktop.
Print public ip address from Ipify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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