#2: readLine() works


import java.net.*;
import java.io.*;

public class Webcat {
 public static void main(String[] args) {
   for (int i = 0; i < args.length; i++) {
    try {
     URL u = new URL(args[i]);
     InputStream in = u.openStream();
     InputStreamReader isr = new InputStreamReader(in);
     BufferedReader br = new BufferedReader(isr);
     String theLine;
     while ((theLine = br.readLine()) != null) {
      System.out.println(theLine);
     }
    } catch (IOException e) { System.err.println(e);} 
  }
 }
}
What readLine() does:
Sees a carriage return, waits to see if next character is a line feed before returning

What readLine() should do:
Sees a carriage return, return, throw away next character if it's a linefeed

Previous | Next | Top
Other Presentations | Cafe au Lait Home
Last Modified May 16, 1999
Copyright 1999 Elliotte Rusty Harold
elharo@metalab.unc.edu