java.lang.Object
java.io.InputStream
org.eclipse.jgit.util.io.AutoLFInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An InputStream that normalizes CRLF to LF.
Existing single CR are not changed to LF but are retained as is.
Optionally, a binary check on the first RawText.getBufferSize()
bytes
is performed and in case of binary files, canonicalization is turned off (for
the complete file). If binary checking determines that the input is
CR/LF-delimited text and the stream has been created for checkout,
canonicalization is also turned off.
- Since:
- 4.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A special exception thrown whenAutoLFInputStream
is told to throw an exception when attempting to read a binary file.static enum
Flags for controlling auto-detection of binary vs. -
Constructor Summary
ConstructorsConstructorDescriptionAutoLFInputStream
(InputStream in, boolean detectBinary) Deprecated.AutoLFInputStream
(InputStream in, boolean detectBinary, boolean abortIfBinary) Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)
insteadAutoLFInputStream
(InputStream in, Set<AutoLFInputStream.StreamFlag> flags) Creates a new InputStream, wrapping the specified stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static AutoLFInputStream
create
(InputStream in, AutoLFInputStream.StreamFlag... flags) Factory method for creating anAutoLFInputStream
with the specifiedflags
.boolean
isBinary()
Whether the stream has detected as a binary so far.int
read()
int
read
(byte[] bs, int off, int len) Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
AutoLFInputStream
Creates a new InputStream, wrapping the specified stream.- Parameters:
in
- raw input streamflags
-AutoLFInputStream.StreamFlag
s controlling the stream behavior;null
is treated as an empty set- Since:
- 5.9
-
AutoLFInputStream
Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)
insteadCreates a new InputStream, wrapping the specified stream.- Parameters:
in
- raw input streamdetectBinary
- whether binaries should be detected- Since:
- 2.0
-
AutoLFInputStream
Deprecated.since 5.9, usecreate(InputStream, StreamFlag...)
insteadCreates 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 Details
-
create
Factory method for creating anAutoLFInputStream
with the specifiedflags
.- Parameters:
in
- raw input streamflags
-AutoLFInputStream.StreamFlag
s controlling the stream behavior- Returns:
- a new
AutoLFInputStream
- Since:
- 5.9
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
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
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
create(InputStream, StreamFlag...)
instead