Here you can find the source of readPage(final String urlStr)
public static String readPage(final String urlStr)
//package com.java2s; import java.io.IOException; import java.net.URL; import java.util.Objects; import java.util.Scanner; public class Main { public static String readPage(final String urlStr) { Objects.requireNonNull(urlStr); final StringBuilder builder = new StringBuilder(); Scanner in = null;/* ww w.j a v a2s . c om*/ try { in = new Scanner(new URL(urlStr).openStream()); while (in.hasNextLine()) { builder.append(in.nextLine()); builder.append("\n"); } } catch (IOException e) { throw new RuntimeException(e); } finally { in.close(); } return builder.toString(); } }