Created
May 16, 2013 01:18
-
-
Save azenla/5588727 to your computer and use it in GitHub Desktop.
Simple IP address getter using Java. Is automatically compiled by Jenkins on commits.
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.IOException; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
public class PublicIPGetter { | |
public static void main(String[] args) throws IOException { | |
HttpURLConnection connection = (HttpURLConnection) new URL("http://bot.whatismyipaddress.com/").openConnection(); | |
connection.connect(); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); | |
System.out.println("Your IP Address is: " + reader.readLine()); | |
reader.close(); | |
connection.disconnect(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment