Index: C:/Lab/VOID/projects/james-trunk/src/java/org/apache/james/util/CRLFTerminatedReader.java =================================================================== --- C:/Lab/VOID/projects/james-trunk/src/java/org/apache/james/util/CRLFTerminatedReader.java (revision 168299) +++ C:/Lab/VOID/projects/james-trunk/src/java/org/apache/james/util/CRLFTerminatedReader.java (working copy) @@ -18,18 +18,17 @@ package org.apache.james.util; import java.io.InputStream; -import java.io.BufferedReader; +import java.io.Reader; import java.io.UnsupportedEncodingException; import java.io.IOException; -import java.io.InputStreamReader; /** * A Reader for use with SMTP or other protocols in which lines * must end with CRLF. Extends BufferedReader and overrides its * readLine() method. The BufferedReader readLine() method cannot * serve for SMTP because it ends lines with either CR or LF alone. */ -public class CRLFTerminatedReader extends BufferedReader { +public class CRLFTerminatedReader extends Reader { public class TerminationException extends IOException { private int where; @@ -51,16 +50,21 @@ /** * Constructs this CRLFTerminatedReader. * @param in an InputStream - * @param charsetName the String name of a supported charset. + * @param charsetName the String name of a supported charset. * "ASCII" is common here. * @throws UnsupportedEncodingException if the named charset * is not supported */ - public CRLFTerminatedReader(InputStream in, String charsetName) - throws UnsupportedEncodingException { - super(new InputStreamReader(in, charsetName)); - } + InputStream in; + public CRLFTerminatedReader(InputStream in) { + this.in = in; + } + + public CRLFTerminatedReader(InputStream in, String enc) throws UnsupportedEncodingException { + this(in); + } + private StringBuffer lineBuffer = new StringBuffer(); private final int EOF = -1, @@ -132,4 +136,28 @@ } }//while }//method readLine() + + + + public int read() throws IOException + { + return in.read(); + } + + public boolean ready() throws IOException { + return in.available() > 0; + } + + public int read(char cbuf[], int off, int len) throws IOException + { + byte [] temp = new byte[len]; + int result = in.read(temp, 0, len); + for (int i=0;i