URL の最初の 5 行を読み取り、それらを逆の順序で出力する単純なプログラムを作成したいので、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);
私がやろうとしていることを行うための最もエレガントな方法は何ですか?