Results 1 to 1 of 1
Thread: Printing contents of a web page
-
Printing contents of a web page
Following code snippet prints contents of a web page, character by character.
Java Code:String str = "http://www.java.forums.org"; try { URL u = new URL(str); URLConnection uc = u.openConnection( ); InputStream raw = uc.getInputStream( ); InputStream buffer = new BufferedInputStream(raw); Reader r = new InputStreamReader(buffer); int c; while ((c = r.read( )) != -1) { System.out.print((char) c); } } catch (MalformedURLException ex) { System.err.println(str + " is not a parseable URL"); } catch (IOException ex) { System.err.println(ex); }
Similar Threads
-
Viewing contents of zip file
By Java Tip in forum Java TipReplies: 0Last Post: 03-03-2008, 05:16 PM -
Concatenation file contents
By Java Tip in forum Java TipReplies: 1Last Post: 02-07-2008, 01:29 PM -
Reading file contents (BufferedReader)
By Java Tip in forum Java TipReplies: 0Last Post: 02-07-2008, 09:00 AM -
Viewing contents of JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 12-21-2007, 03:12 PM -
Reading web contents
By javaplus in forum NetworkingReplies: 2Last Post: 11-29-2007, 10:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks