Skip to content

Instantly share code, notes, and snippets.

@Vachok
Last active September 10, 2023 02:48
Show Gist options
  • Save Vachok/7d4f517627eb31c4853d0132a5f37313 to your computer and use it in GitHub Desktop.
Save Vachok/7d4f517627eb31c4853d0132a5f37313 to your computer and use it in GitHub Desktop.
Узнаём внешний адрес
private String withMyIP() {
StringBuilder stringBuilder = new StringBuilder();
try {
URL checkIP = new URL("http://checkip.amazonaws.com");
try (InputStream inputStream = checkIP.openStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)))
{
while (bufferedReader.ready()) stringBuilder.append(bufferedReader.readLine()).append(" ");
}
}
catch (IOException e) {
e
}
return stringBuilder.toString();
}
@Vachok
Copy link
Author

Vachok commented Sep 10, 2023

Смысл - идея. Не то что строчка возвращается - это частное

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment