Class 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 8000 bytes is performed and in case of binary files, canonicalization is turned off (for the complete file).
    Since:
    4.3
    • 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()  
      void flush()
      void write​(byte[] b)
      void write​(byte[] b, int startOff, int startLen)
      void write​(int b)
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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 - an OutputStream object.
      • AutoLFOutputStream

        public AutoLFOutputStream​(java.io.OutputStream out,
                                  boolean detectBinary)

        Constructor for AutoLFOutputStream.

        Parameters:
        out - an OutputStream object.
        detectBinary - whether binaries should be detected
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int startOff,
                          int startLen)
                   throws java.io.IOException
        Overrides:
        write in class java.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:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException