Scripts: Scripts: Java :: Using tools :: Library Article #3

Developer's Section

Read a Webpage using Java
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Average Votes: (1990)
Rate It:   

Learn to read the contents of a webpage using the tools.

In this article we will be looking at one of the most important components: the URL object. When we instantiate an object of type URL, we can create a stream using the URL.openStream() method. This in turn will allow us to use an InputStreamReader object to read the contents of the script into a Buffer Reader.


 Code Snippet 1


public class readSite {

  public static void main(String args[]) {
   //read the contents of
   //and output them to the console window
    URL siteUrl = new URL("");
    BufferedReader in = new BufferedReader(
                                        new InputStreamReader(

    String inputLine;

    while ((inputLine = in.readLine()) != null)


  catch(MalformedURLException e)
   System.out.println("The Url doesn't exist");
  catch(IOException e)
   System.out.println("an Exception has occured");



See other Scripts in Using tools


Submit Your Scripts:

System Message:
  • Your Java script has been sent. Please allow 48 hours for processing.

If you would like to have your Java scripts published in this section please fill out
the form below:
*Your Name or
Home Town:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]


© 2018 Erobo Software, Inc. All Rights Reserved. | Read Privacy Notice | RSS