Answers for "java http connection download file"

-1

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();
    
}
Posted by: Guest on August-16-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language