feat: add WebUtils Class

This commit is contained in:
Simon Giesel 2020-05-04 18:32:55 +02:00
parent 46c34f137f
commit 774ac9b9bd

View file

@ -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();
}
}