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
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[]binbufprivate intbinbufcntprivate intbufprivate 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(boolean complete)voidflush()voidwrite(byte[] b)voidwrite(byte[] b, int startOff, int startLen)voidwrite(int b)
-
-
-
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(boolean complete) 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
-
-