SK.gnome.dwarf.utils.io
Class SafeLineReader

java.lang.Object
  extended byjava.io.Reader
      extended byjava.io.FilterReader
          extended bySK.gnome.dwarf.utils.io.SafeLineReader

public class SafeLineReader
extends java.io.FilterReader

Provides network-safe line Reader implementation.

It can be used to read lines from the java.io.Reader class. The only difference is that it can be setup to accept the CRLF sequence as the line separator only. This sequence is frequently used by many network protocols as the only acceptable way how to terminate the lines. In this case, a single LF character (without the preceding CR) is included to the line content, while a single CR character (without the following LF) causes an IOException to be thrown.

This class is based on an example from The Java Network Programming, 2nd edition, written by Elliotte Rusty Harold.


Field Summary
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
SafeLineReader(java.io.InputStream in, boolean crlfOnly, int limit, java.lang.String encoding)
           
SafeLineReader(java.io.Reader in)
           
SafeLineReader(java.io.Reader in, boolean crlfOnly, int limit)
           
 
Method Summary
 int countLines()
           
 java.lang.String readLine()
           
 
Methods inherited from class java.io.FilterReader
close, mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeLineReader

public SafeLineReader(java.io.Reader in)

SafeLineReader

public SafeLineReader(java.io.Reader in,
                      boolean crlfOnly,
                      int limit)

SafeLineReader

public SafeLineReader(java.io.InputStream in,
                      boolean crlfOnly,
                      int limit,
                      java.lang.String encoding)
               throws java.io.UnsupportedEncodingException
Method Detail

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Throws:
java.io.IOException

countLines

public int countLines()
               throws java.io.IOException
Throws:
java.io.IOException


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.