Java URL Read getText(String url)

Here you can find the source of getText(String url)

Description

get Text

License

Creative Commons License

Declaration

public static String getText(String url) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

import java.net.*;
import java.io.*;

public class Main {
    public static String getText(String url) throws Exception {
        URL website = new URL(url);
        URLConnection connection = website.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "iso-8859-2"));

        StringBuilder response = new StringBuilder();
        String inputLine;/*from  w  w w . j  a  va  2s . c o  m*/

        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

        return response.toString();
    }
}

Related

  1. getRemoteFileSize(URL url)
  2. getStreamByConnection(final HttpURLConnection con)
  3. getStringFromConnection(HttpURLConnection connection)
  4. getStringFromURL(String URLString)
  5. getText(HttpURLConnection conn)
  6. getText(String url)
  7. getText(URL url)
  8. getTextFromURL(final String url)
  9. getTextFromURL(URL url)