Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Java Text files

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
7of9121098
Asked:
7of9121098
  • 2
1 Solution
 
objectsCommented:
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
 
objectsCommented:
:-)

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

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now