From 774ac9b9bd82d4cf3753a3288ee06cce08a922b2 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 May 2020 18:32:55 +0200 Subject: [PATCH] feat: add WebUtils Class --- .../de/cliffbreak/varo/uitls/WebUtils.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 varo/src/main/java/de/cliffbreak/varo/uitls/WebUtils.java diff --git a/varo/src/main/java/de/cliffbreak/varo/uitls/WebUtils.java b/varo/src/main/java/de/cliffbreak/varo/uitls/WebUtils.java new file mode 100644 index 0000000..e9e0050 --- /dev/null +++ b/varo/src/main/java/de/cliffbreak/varo/uitls/WebUtils.java @@ -0,0 +1,26 @@ +package de.cliffbreak.varo.uitls; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +public class WebUtils { + + public static String GET(String url) throws MalformedURLException, IOException { + HttpURLConnection connection = ((HttpURLConnection) (new URL(url)).openConnection()); + connection.setRequestMethod("GET"); + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuffer content = new StringBuffer(); + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); + } + in.close(); + connection.disconnect(); + return content.toString(); + } + +} \ No newline at end of file