Skip to content

Instantly share code, notes, and snippets.

@izimin
Last active April 18, 2024 19:07
Show Gist options
  • Select an option

  • Save izimin/656dae141485e63b3a638b49d7300ca1 to your computer and use it in GitHub Desktop.

Select an option

Save izimin/656dae141485e63b3a638b49d7300ca1 to your computer and use it in GitHub Desktop.
HTML content by URL
private static String getHtmlContentByUrl(String url) {
String content = null;
URLConnection connection;
try {
connection = new URL(url).openConnection();
Scanner scanner = new Scanner(connection.getInputStream());
scanner.useDelimiter("\\Z");
content = scanner.next();
} catch (Exception ex) {
ex.printStackTrace();
}
return content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment