Here you can find the source of get(String urlStr)
public static String get(String urlStr)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.List; import java.util.stream.Collectors; public class Main { public static String get(String urlStr) { try {/* w w w . j a v a 2s . c o m*/ URL url = new URL(urlStr); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setInstanceFollowRedirects(true); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); List<String> lines = in.lines().collect(Collectors.toList()); in.close(); return String.join("\n", lines); } catch (IOException e) { return null; } } }