java http connection download file
private void download(){
URL url = new URL("https://www.vogella.com/");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
String readStream = readStream(con.getInputStream());
}
private static String readStream(InputStream in) {
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in));) {
String nextLine = "";
while ((nextLine = reader.readLine()) != null) {
sb.append(nextLine + newLine);
}
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}