Results 1 to 2 of 2
- 03-29-2011, 07:16 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
reading lines from URL and printing backwards
I want to write a simple program that reads the first five lines of a URL and then prints them out in reverse order, so it'd be line 5, line 4, line 3, line 2, line 1.
Here's what I've got so far:
What would be the most elegant way to do what I'm trying to do?Java Code:public static void main(String[] arg) throws Exception { BufferedReader keyboard; String inputLine; keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Please enter the name of a company (without spaces): "); System.out.flush(); /* Make sure the line is printed immediately. */ inputLine = keyboard.readLine(); URL u = new URL("http://www." + inputLine + ".com/"); InputStream ins = u.openStream(); System.out.println(u); InputStreamReader isr = new InputStreamReader(ins); BufferedReader readURL = new BufferedReader(isr);
- 03-30-2011, 08:18 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Similar Threads
-
printing string backwards and printing every other
By droidus in forum New To JavaReplies: 22Last Post: 03-10-2011, 09:17 AM -
Two '\n' characters between lines while reading File
By subith86 in forum New To JavaReplies: 6Last Post: 02-26-2011, 09:56 AM -
problem reading a files lines
By j187 in forum New To JavaReplies: 1Last Post: 12-17-2010, 12:43 AM -
inputting and writing a file backwards
By jigglywiggly in forum New To JavaReplies: 0Last Post: 03-18-2009, 07:24 PM -
Reading specific lines
By ivvgangadhar in forum New To JavaReplies: 8Last Post: 01-12-2009, 08:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks