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.OutputStreamAn OutputStream that reduces CRLF to LF.Existing single CR are not changed to LF, but retained as is.
A binary check on the first 8000 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[]binbufprivate intbinbufcntprivate intbuf(package private) static intBUFFER_SIZEprivate booleandetectBinaryprivate booleanisBinaryprivate byte[]onebytebufprivate java.io.OutputStreamout
-
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 intbuffer(byte[] b, int off, int len)voidclose()private voiddecideMode()voidflush()voidwrite(byte[] b)voidwrite(byte[] b, int startOff, int startLen)voidwrite(int b)
-
-
-
Field Detail
-
BUFFER_SIZE
static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
out
private final java.io.OutputStream out
-
buf
private int buf
-
binbuf
private byte[] binbuf
-
onebytebuf
private byte[] onebytebuf
-
binbufcnt
private int binbufcnt
-
detectBinary
private boolean detectBinary
-
isBinary
private boolean isBinary
-
-
Constructor Detail
-
AutoLFOutputStream
public AutoLFOutputStream(java.io.OutputStream out)
Constructor for AutoLFOutputStream.- Parameters:
out- anOutputStreamobject.
-
AutoLFOutputStream
public AutoLFOutputStream(java.io.OutputStream out, boolean detectBinary)Constructor for AutoLFOutputStream.- Parameters:
out- anOutputStreamobject.detectBinary- whether binaries should be detected
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int startOff, int startLen) throws java.io.IOException- Overrides:
writein 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() throws java.io.IOException- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
-