Package org.eclipse.jgit.util.io
Class AutoLFOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.eclipse.jgit.util.io.AutoLFOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class AutoLFOutputStream extends java.io.OutputStream
An OutputStream that reduces CRLF to LF.Existing single CR are not changed to LF, but retained as is.
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 the binary check determines that the input is not binary but text with CR/LF, canonicalization is also turned off.- Since:
- 4.3
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
binbuf
private int
binbufcnt
private int
buf
private boolean
detectBinary
private boolean
isBinary
private byte[]
onebytebuf
private java.io.OutputStream
out
-
Constructor Summary
Constructors Constructor Description AutoLFOutputStream(java.io.OutputStream out)
Constructor for AutoLFOutputStream.AutoLFOutputStream(java.io.OutputStream out, boolean detectBinary)
Constructor for AutoLFOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
buffer(byte[] b, int off, int len)
void
close()
private void
decideMode(boolean complete)
void
flush()
void
write(byte[] b)
void
write(byte[] b, int startOff, int startLen)
void
write(int b)
-
-
-
Constructor Detail
-
AutoLFOutputStream
public AutoLFOutputStream(java.io.OutputStream out)
Constructor for AutoLFOutputStream.- Parameters:
out
- anOutputStream
object.
-
AutoLFOutputStream
public AutoLFOutputStream(java.io.OutputStream out, boolean detectBinary)
Constructor for AutoLFOutputStream.- Parameters:
out
- anOutputStream
object.detectBinary
- whether binaries should be detected
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int startOff, int startLen) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
buffer
private int buffer(byte[] b, int off, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
decideMode
private void decideMode(boolean complete) throws java.io.IOException
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
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.OutputStream
- Throws:
java.io.IOException
-
-