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.

Recommended Answers

All 4 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.