Solved

Java Text files

Posted on 2001-06-08
2
157 Views
Last Modified: 2010-03-31
I'm looking for a script in Java or JSP that allows me to enter a URL and extract all of the HTML Code into a text file on the Server? Does anyone have a script out there I can look at, or know of a place I can get a hold of one?

 Many thanks
0
Comment
Question by:7of9121098
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6169817
Try something like this:


URL url = new URL("http://www.abc.com");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
PrintWriter out = new PrintWriter(new FileOutputStream("output.html"));
String line;
while (null!=(line=in.readLine()))
{
  out.println(line);
}
in.close();
out.close();
0
 
LVL 92

Expert Comment

by:objects
ID: 6780603
:-)

Mick Barry
Brainbench MVP for Java 1
http://www.brainbench.com

http://www.objects.com.au
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question