Package org.apache.commons.io.input
Class UnixLineEndingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.io.input.AbstractLineEndingInputStream
-
- org.apache.commons.io.input.UnixLineEndingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class UnixLineEndingInputStream extends AbstractLineEndingInputStream
A filtering input stream that ensures the content will have UNIX-style line endings, LF.- Since:
- 2.5
-
-
Field Summary
-
Fields inherited from class org.apache.commons.io.input.AbstractLineEndingInputStream
atEos, atSlashCr, atSlashLf, in, lineFeedAtEos
-
-
Constructor Summary
Constructors Constructor Description UnixLineEndingInputStream(java.io.InputStream inputStream, boolean lineFeedAtEos)Constructs an input stream that filters another stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private inthandleEos(boolean previousWasSlashCr)Handles the end of stream condition.intread()private intreadUpdate()Reads the next item from the target, updating internal flags in the process-
Methods inherited from class org.apache.commons.io.input.AbstractLineEndingInputStream
close, mark
-
-
-
-
Constructor Detail
-
UnixLineEndingInputStream
public UnixLineEndingInputStream(java.io.InputStream inputStream, boolean lineFeedAtEos)Constructs an input stream that filters another stream- Parameters:
inputStream- The input stream to wrap.lineFeedAtEos- true to ensure that the file ends with LF.
-
-
Method Detail
-
handleEos
private int handleEos(boolean previousWasSlashCr)
Handles the end of stream condition.- Parameters:
previousWasSlashCr- Indicates if the last seen was a\r.- Returns:
- The next char to output to the stream.
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
readUpdate
private int readUpdate() 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- If an I/O error occurs.
-
-