Results 1 to 1 of 1
-
Reading text from a URL using BufferedReader
The code below reads the contents of a web page using BufferedReader.
Java Code:try { // Create a URL object URL url = new URL("http://www.java-forums.org:80/sendmessage.php"); // Read all of the text returned by the HTTP server BufferedReader in = new BufferedReader (new InputStreamReader(url.openStream())); String htmlText; while ((htmlText = in.readLine()) != null) { // Keep in mind that readLine() strips the newline characters System.out.println(htmlText); } in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
Similar Threads
-
Reading a file from Applet (BufferedReader)
By Java Tip in forum Java TipReplies: 1Last Post: 06-22-2008, 10:51 PM -
Reading file contents (BufferedReader)
By Java Tip in forum Java TipReplies: 0Last Post: 02-07-2008, 09:00 AM -
Reading int values using BufferedReader
By Java Tip in forum Java TipReplies: 2Last Post: 01-24-2008, 07:26 PM -
Reading text file
By Lennon-Guru in forum New To JavaReplies: 1Last Post: 12-15-2007, 11:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks