我想编写一个简单的程序,它读取 URL 的前五行,然后以相反的顺序打印出来,所以它是第 5 行、第 4 行、第 3 行、第 2 行、第 1 行。
这是我到目前为止所得到的:
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();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader readURL = new BufferedReader(isr);
做我想做的事情的最优雅的方式是什么?