Java URL Connection getPageContent(String inputUrlString)

Here you can find the source of getPageContent(String inputUrlString)

Description

get Page Content

License

Open Source License

Declaration

public static String getPageContent(String inputUrlString) throws IOException 

Method Source Code


//package com.java2s;
import java.io.IOException;

import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;

public class Main {
    private static final String END_OF_INPUT = "\\Z";

    public static String getPageContent(String inputUrlString) throws IOException {
        URL url = new URL(inputUrlString);
        return getPageContent(url);
    }/*from www. j a  v  a2 s. c o  m*/

    public static String getPageContent(URL inputUrl) throws IOException {
        String result = null;
        URLConnection connection = null;
        connection = inputUrl.openConnection();
        Scanner scanner = new Scanner(connection.getInputStream());
        scanner.useDelimiter(END_OF_INPUT);
        result = scanner.next();
        return result;
    }
}

Related

  1. getLength(String htmlUrl)
  2. getLines(final URL url, final int linesToRead)
  3. getOutputStream(final URL outputURL)
  4. getOutputStream(URL url)
  5. getPage(String url)
  6. getRealURL(URL url)
  7. getRemoteTimestamp(final String url)
  8. getRequest(URLConnection conn)
  9. getRequestHeaders(URLConnection conn)