org.apache.james.util
Class CRLFTerminatedReader

java.lang.Object
  extended byjava.io.Reader
      extended byorg.apache.james.util.CRLFTerminatedReader

public class CRLFTerminatedReader
extends Reader

A Reader for use with SMTP or other protocols in which lines must end with CRLF. Extends Reader and overrides its readLine() method. The Reader readLine() method cannot serve for SMTP because it ends lines with either CR or LF alone.


Nested Class Summary
 class CRLFTerminatedReader.LineLengthExceededException
           
 class CRLFTerminatedReader.TerminationException
           
 
Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
CRLFTerminatedReader(InputStream in)
           
CRLFTerminatedReader(InputStream in, String enc)
           
 
Method Summary
 void close()
           
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 String readLine()
          Read a line of text which is terminated by CRLF.
 boolean ready()
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRLFTerminatedReader

public CRLFTerminatedReader(InputStream in)

CRLFTerminatedReader

public CRLFTerminatedReader(InputStream in,
                            String enc)
                     throws UnsupportedEncodingException
Method Detail

readLine

public String readLine()
                throws IOException
Read a line of text which is terminated by CRLF. The concluding CRLF characters are not returned with the String, but if either CR or LF appears in the text in any other sequence it is returned in the String like any other character. Some characters at the end of the stream may be lost if they are in a "line" not terminated by CRLF.

Returns:
either a String containing the contents of a line which must end with CRLF, or null if the end of the stream has been reached, possibly discarding some characters in a line not terminated with CRLF.
Throws:
IOException - if an I/O error occurs.

read

public int read()
         throws IOException
Throws:
IOException

ready

public boolean ready()
              throws IOException
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException


"Copyright © 1999-2006 Apache Jakarta Project. All Rights Reserved."