Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String getServerIP() {
- String urlloc="http://checkip.amazonaws.com/";
- try {
- URL url = new URL(urlloc);
- URLConnection openConnection = url.openConnection();
- openConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
- Scanner r = new Scanner(openConnection.getInputStream());
- StringBuilder sb = new StringBuilder();
- while (r.hasNext()) {
- sb.append(r.next());
- }
- r.close();
- return sb.toString();
- } catch (IOException e) {
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment