1
2private void download(){
3 URL url = new URL("https://www.vogella.com/");
4 HttpURLConnection con = (HttpURLConnection) url.openConnection();
5 String readStream = readStream(con.getInputStream());
6}
7private static String readStream(InputStream in) {
8 StringBuilder sb = new StringBuilder();
9 try (BufferedReader reader = new BufferedReader(new InputStreamReader(in));) {
10 String nextLine = "";
11 while ((nextLine = reader.readLine()) != null) {
12 sb.append(nextLine + newLine);
13 }
14 } catch (IOException e) {
15 e.printStackTrace();
16 }
17 return sb.toString();
18
19}
20