Package org.apache.commons.io.input
Class WindowsLineEndingInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.WindowsLineEndingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
A filtering input stream that ensures the content will have Windows line endings, CRLF.
- Since:
- 2.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private boolean
private final InputStream
private boolean
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionWindowsLineEndingInputStream
(InputStream in, boolean ensureLineFeedAtEndOfFile) Constructs an input stream that filters another stream -
Method Summary
Methods inherited from class java.io.InputStream
available, markSupported, read, read, reset, skip
-
Field Details
-
atEos
private boolean atEos -
atSlashCr
private boolean atSlashCr -
atSlashLf
private boolean atSlashLf -
in
-
injectSlashLf
private boolean injectSlashLf -
lineFeedAtEndOfFile
private final boolean lineFeedAtEndOfFile
-
-
Constructor Details
-
WindowsLineEndingInputStream
Constructs an input stream that filters another stream- Parameters:
in
- The input stream to wrapensureLineFeedAtEndOfFile
- true to ensure that the file ends with CRLF
-
-
Method Details
-
close
Closes the stream. Also closes the underlying stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- upon error
-
handleEos
private int handleEos()Handles the end of stream condition.- Returns:
- The next char to output to the stream
-
mark
public void mark(int readLimit) - Overrides:
mark
in classInputStream
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
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
-