Package org.apache.commons.io.input
Class UnixLineEndingInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.UnixLineEndingInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
A filtering input stream that ensures the content will have unix-style line endings, LF.
- Since:
- 2.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate booleanprivate booleanprivate booleanprivate final InputStream -
Constructor Summary
ConstructorsConstructorDescriptionUnixLineEndingInputStream(InputStream in, boolean ensureLineFeedAtEndOfFile) Create an input stream that filters another stream -
Method Summary
Methods inherited from class java.io.InputStream
available, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
slashNSeen
private boolean slashNSeen -
slashRSeen
private boolean slashRSeen -
eofSeen
private boolean eofSeen -
target
-
ensureLineFeedAtEndOfFile
private final boolean ensureLineFeedAtEndOfFile
-
-
Constructor Details
-
UnixLineEndingInputStream
Create an input stream that filters another stream- Parameters:
in- The input stream to wrapensureLineFeedAtEndOfFile- true to ensure that the file ends with LF
-
-
Method Details
-
readWithUpdate
Reads the next item from the target, updating internal flags in the process- Returns:
- the next int read from the target stream
- Throws:
IOException- upon error
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
eofGame
private int eofGame(boolean previousWasSlashR) Handles the eof-handling at the end of the stream- Parameters:
previousWasSlashR- Indicates if the last seen was a \r- Returns:
- The next char to output to the stream
-
close
Closes the stream. Also closes the underlying stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- upon error
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-