FileDocCategorySizeDatePackage
SafeBufferedReader.javaAPI DocExample905Sat Sep 09 19:52:10 BST 2000com.macfaq.io

SafeBufferedReader

public class SafeBufferedReader extends BufferedReader

Fields Summary
private boolean
lookingForLineFeed
Constructors Summary
public SafeBufferedReader(Reader in)

    this(in, 1024);
  
public SafeBufferedReader(Reader in, int bufferSize)

    super(in, bufferSize);
  
Methods Summary
public java.lang.StringreadLine()

  
       
    StringBuffer sb = new StringBuffer("");
    while (true) {
      int c = this.read();
      if (c == -1) { // end of stream
        return null;
      }
      else if (c == '\n") {
        if (lookingForLineFeed) {
          lookingForLineFeed = false;
          continue;
        }
        else {
          return sb.toString();
        }
      }
      else if (c == '\r") {
        lookingForLineFeed = true;
        return sb.toString();
      }
      else {
        lookingForLineFeed = false;
        sb.append((char) c);
      }
    }