Java URL Load readPage(final String urlStr)

Here you can find the source of readPage(final String urlStr)

Description

read Page

License

Open Source License

Declaration

public static String readPage(final String urlStr) 

Method Source Code


//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();
    }
}

Related

  1. readListFile(URL listFile)
  2. readListFile(URL listFile)
  3. readMappingFile(final URL filename)
  4. readModelFromUrl(URL file, Class clazz)
  5. readNetFile(String urlstr)
  6. readPage(URL url)
  7. readProperties(final URL url)
  8. readProperties(final URL url)
  9. readProperties(URL resource)