org.apache.james.mime4j.io
Class EOLConvertingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.james.mime4j.io.EOLConvertingInputStream
All Implemented Interfaces:
java.io.Closeable

public class EOLConvertingInputStream
extends java.io.InputStream

InputStream which converts \r bytes not followed by \n and \n not preceded by \r to \r\n.


Field Summary
static int CONVERT_BOTH
          Converts single '\r' and '\n' to '\r\n'
static int CONVERT_CR
          Converts single '\r' to '\r\n'
static int CONVERT_LF
          Converts single '\n' to '\r\n'
 
Constructor Summary
EOLConvertingInputStream(java.io.InputStream in)
          Creates a new EOLConvertingInputStream instance converting bytes in the given InputStream.
EOLConvertingInputStream(java.io.InputStream in, int flags)
          Creates a new EOLConvertingInputStream instance converting bytes in the given InputStream.
 
Method Summary
 void close()
          Closes the underlying stream.
 int read()
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERT_CR

public static final int CONVERT_CR
Converts single '\r' to '\r\n'

See Also:
Constant Field Values

CONVERT_LF

public static final int CONVERT_LF
Converts single '\n' to '\r\n'

See Also:
Constant Field Values

CONVERT_BOTH

public static final int CONVERT_BOTH
Converts single '\r' and '\n' to '\r\n'

See Also:
Constant Field Values
Constructor Detail

EOLConvertingInputStream

public EOLConvertingInputStream(java.io.InputStream in)
Creates a new EOLConvertingInputStream instance converting bytes in the given InputStream. The flag CONVERT_BOTH is the default.

Parameters:
in - the InputStream to read from.

EOLConvertingInputStream

public EOLConvertingInputStream(java.io.InputStream in,
                                int flags)
Creates a new EOLConvertingInputStream instance converting bytes in the given InputStream.

Parameters:
in - the InputStream to read from.
flags - one of CONVERT_CR, CONVERT_LF or CONVERT_BOTH.
Method Detail

close

public void close()
           throws java.io.IOException
Closes the underlying stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - on I/O errors.

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read()


Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.