Class CRLFTerminatedReader

java.lang.Object
java.io.Reader
org.subethamail.smtp.io.CRLFTerminatedReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

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. JSS: The readline() method of this class has been 'enchanced' from the Apache JAMES version to throw an IOException if the line is greater than or equal to MAX_LINE_LENGTH (998) which is defined in RFC 2822.
  • Constructor Details

  • Method Details

    • 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
      Overrides:
      read in class Reader
      Throws:
      IOException
    • ready

      public boolean ready() throws IOException
      Overrides:
      ready in class Reader
      Throws:
      IOException
    • read

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

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