org.apache.james.util
Class CRLFTerminatedReader

java.lang.Object
  extended by java.io.Reader
      extended by org.apache.james.util.CRLFTerminatedReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class CRLFTerminatedReader
extends java.io.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(java.io.InputStream in)
           
CRLFTerminatedReader(java.io.InputStream in, java.lang.String enc)
           
 
Method Summary
 void close()
           
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 java.lang.String readLine()
          Read a line of text which is terminated by CRLF.
 boolean ready()
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, 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(java.io.InputStream in)

CRLFTerminatedReader

public CRLFTerminatedReader(java.io.InputStream in,
                            java.lang.String enc)
                     throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException
Method Detail

readLine

public java.lang.String readLine()
                          throws java.io.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:
java.io.IOException - if an I/O error occurs.

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.Reader
Throws:
java.io.IOException

ready

public boolean ready()
              throws java.io.IOException
Overrides:
ready in class java.io.Reader
Throws:
java.io.IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.