Package com.sun.mail.util

# Class LineInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.sun.mail.util.LineInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class LineInputStream extends FilterInputStream
LineInputStream supports reading CRLF terminated lines that contain only US-ASCII characters from an input stream. Provides functionality that is similar to the deprecated `DataInputStream.readLine()`. Expected use is to read lines as String objects from an IMAP/SMTP/etc. stream.

This class also supports UTF-8 data by calling the appropriate constructor. Or, if the System property `mail.mime.allowutf8` is set to true, an attempt will be made to interpret the data as UTF-8, falling back to treating it as an 8-bit charset if that fails.

LineInputStream is implemented as a FilterInputStream, so one can just wrap it around any input stream and read bytes from this filter.

Author:
  John Mani, Bill Shannon

## Field Summary

### Fields inherited from class java.io.FilterInputStream

`in`

## Constructor Summary

Constructors
Constructor
Description
`LineInputStream(InputStream in)`
`LineInputStream(InputStream in, boolean allowutf8)`

## Method Summary

Modifier and Type
Method
Description
`String`
`readLine()`
Read a line containing only ASCII characters from the input stream.

### Methods inherited from class java.io.FilterInputStream

`available, close, mark, markSupported, read, read, read, reset, skip`

### Methods inherited from class java.io.InputStream

`nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### LineInputStream

public LineInputStream(InputStream in)

### LineInputStream

public LineInputStream(InputStream in, boolean allowutf8)

Parameters:
  `in` - the InputStream
  `allowutf8` - allow UTF-8 characters?
Since:
  JavaMail 1.6

## Method Details

### readLine

public String readLine() throws IOException
Read a line containing only ASCII characters from the input stream. A line is terminated by a CR or NL or CR-NL sequence. A common error is a CR-CR-NL sequence, which will also terminate a line. The line terminator is not returned as part of the returned String. Returns null if no data is available.

This class is similar to the deprecated `DataInputStream.readLine()`

Returns:
  the line
Throws:
  `IOException` - for I/O errors