0

I want to know how can we read the texts that are in a webpage and store it in a file in our local disk. i want to read the text line by line and store it in the text file in my local disk. can anyone help me???

4
Contributors
11
Replies
15
Views
8 Years
Discussion Span
Last Post by muthu_tek
Featured Replies
  • 1
    Ezzaral 2,714   8 Years Ago

    I already provided links above that cover the major steps involved. If you need more general links on Java, look through the "Read Me: Starting Java" thread that is stickied at the top of the forum. Read More

0

ok!!! i m new to java.. can i do this using net beans? i created a sample html page with some text in that. shud i write the codin in a java class or servlet? what package to import?

0

You can write it in any editor that you please. Read the links and check the API docs for those classes that you do not know.

0
try {
        // Create a URL for the desired page
        URL url = new URL("http://localhost:8084/WebAppliccation2/sample.html");

        // Read all the text returned by the server
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String str;
        while ((str = in.readLine()) != null) {

}
in.close();

wat shud i write in the while loop??

Edited by Dani: Formatting fixed

0
try {
        // Create a URL for the desired page
        URL url = new URL("http://localhost:8084/WebAppliccation2/sample.html");

        // Read all the text returned by the server
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String str;
        while ((str = in.readLine()) != null) {

}
in.close();

wat shud i write in the while loop??

Edited by Dani: Formatting fixed

1

I already provided links above that cover the major steps involved. If you need more general links on Java, look through the "Read Me: Starting Java" thread that is stickied at the top of the forum.

Votes + Comments
You have a lot of patience.
0

Hi Guys,
I have one doubt in above discussion,If we do like which you discussed above,We can get webpage source code only,If we want text means content ,then what we do guys.Any suggestion?

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.