0

I am able to write a java program to access a particular url , and get the data , but the data is in raw format and the complete source is printed in the terminal .

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

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL go = new URL("http://www.google.com/");
        URLConnection uc = go.openConnection();

        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                uc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
    }
}

I want that raw data to be displayed as a web page. Is there any way to do that.

Edited by mike_2000_17: Fixed formatting

4
Contributors
4
Replies
15
Views
7 Years
Discussion Span
Last Post by invadev
0

I was trying to the code for displaying the url content. but its not showing that specific url. Its shows some html format. what is the format of creating the url connection and it will display that webpage content. for example i would give https://www.google.com it have to display or connect to the webpage of google. pls do the needful.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.