Last active
April 18, 2024 19:07
-
-
Save izimin/656dae141485e63b3a638b49d7300ca1 to your computer and use it in GitHub Desktop.
HTML content by URL
This file contains hidden or 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
| 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