Package org.eclipse.jgit.util.io
Class AutoCRLFOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.eclipse.jgit.util.io.AutoCRLFOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class AutoCRLFOutputStream extends java.io.OutputStreamAn OutputStream that expands LF to CRLF. Existing CRLF are not expanded to CRCRLF, 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).
-
-
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 AutoCRLFOutputStream(java.io.OutputStream out)Constructor for AutoCRLFOutputStream.AutoCRLFOutputStream(java.io.OutputStream out, boolean detectBinary)Constructor for AutoCRLFOutputStream.
-
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
-
AutoCRLFOutputStream
public AutoCRLFOutputStream(java.io.OutputStream out)
Constructor for AutoCRLFOutputStream.
- Parameters:
out- aOutputStreamobject.
-
AutoCRLFOutputStream
public AutoCRLFOutputStream(java.io.OutputStream out, boolean detectBinary)Constructor for AutoCRLFOutputStream.
- Parameters:
out- aOutputStreamobject.detectBinary- whether binaries should be detected- Since:
- 4.3
-
-
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
-
-