Package org.eclipse.jgit.util.io
Class AutoLFInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.eclipse.jgit.util.io.AutoLFInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class AutoLFInputStream extends java.io.InputStream
An InputStream that normalizes CRLF to LF. Existing single CR are not changed to LF, but retained as is. Optionally, a binary check on the first 8000 bytes is performed and in case of binary files, canonicalization is turned off (for the complete file).This is the former EolCanonicalizingInputStream with a new name in order to have same naming for all LF / CRLF streams
- Since:
- 4.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AutoLFInputStream.IsBinaryException
A special exception thrown whenAutoLFInputStream
is told to throw an exception when attempting to read a binary file.
-
Field Summary
Fields Modifier and Type Field Description private boolean
abortIfBinary
private byte[]
buf
private int
cnt
private boolean
detectBinary
private java.io.InputStream
in
private boolean
isBinary
private int
ptr
private byte[]
single
-
Constructor Summary
Constructors Constructor Description AutoLFInputStream(java.io.InputStream in, boolean detectBinary)
Creates a new InputStream, wrapping the specified streamAutoLFInputStream(java.io.InputStream in, boolean detectBinary, boolean abortIfBinary)
Creates a new InputStream, wrapping the specified stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private boolean
fillBuffer()
boolean
isBinary()
Whether the stream has detected as a binary so far.int
read()
int
read(byte[] bs, int off, int len)
-
-
-
Constructor Detail
-
AutoLFInputStream
public AutoLFInputStream(java.io.InputStream in, boolean detectBinary)
Creates a new InputStream, wrapping the specified stream- Parameters:
in
- raw input streamdetectBinary
- whether binaries should be detected- Since:
- 2.0
-
AutoLFInputStream
public AutoLFInputStream(java.io.InputStream in, boolean detectBinary, boolean abortIfBinary)
Creates a new InputStream, wrapping the specified stream- Parameters:
in
- raw input streamdetectBinary
- whether binaries should be detectedabortIfBinary
- throw an IOException if the file is binary- Since:
- 3.3
-
-
Method Detail
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] bs, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
isBinary
public boolean isBinary()
Whether the stream has detected as a binary so far.- Returns:
- true if the stream has detected as a binary so far.
- Since:
- 3.3
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
fillBuffer
private boolean fillBuffer() throws java.io.IOException
- Throws:
java.io.IOException
-
-