The code below reads the contents of a web page using BufferedReader.

Java Code:
try {
            // Create a URL object
            URL url = new URL("http://www.java-forums.org:80/sendmessage.php");

            // Read all of the text returned by the HTTP server
            BufferedReader in = new BufferedReader
            (new InputStreamReader(url.openStream()));

            String htmlText;

            while ((htmlText = in.readLine()) != null) {
                // Keep in mind that readLine() strips the newline characters
                System.out.println(htmlText);
            }
            in.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }