Package org.apache.commons.io.input
Class WindowsLineEndingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.io.input.WindowsLineEndingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class WindowsLineEndingInputStream extends java.io.InputStreamA filtering input stream that ensures the content will have Windows line endings, CRLF.- Since:
- 2.5
-
-
Field Summary
Fields Modifier and Type Field Description private booleanatEosprivate booleanatSlashCrprivate booleanatSlashLfprivate java.io.InputStreaminprivate booleaninjectSlashLfprivate booleanlineFeedAtEndOfFile
-
Constructor Summary
Constructors Constructor Description WindowsLineEndingInputStream(java.io.InputStream in, boolean ensureLineFeedAtEndOfFile)Constructs an input stream that filters another stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the stream.private inthandleEos()Handles the end of stream condition.voidmark(int readlimit)intread()private intreadWithUpdate()Reads the next item from the target, updating internal flags in the process
-
-
-
Constructor Detail
-
WindowsLineEndingInputStream
public WindowsLineEndingInputStream(java.io.InputStream in, boolean ensureLineFeedAtEndOfFile)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 Detail
-
close
public void close() throws java.io.IOExceptionCloses the stream. Also closes the underlying stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.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:
markin classjava.io.InputStream
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
readWithUpdate
private int readWithUpdate() throws java.io.IOExceptionReads the next item from the target, updating internal flags in the process- Returns:
- the next int read from the target stream
- Throws:
java.io.IOException- upon error
-
-