Class AutoCRLFInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class AutoCRLFInputStream
    extends java.io.InputStream
    An InputStream that expands LF to CRLF. Existing CRLF are not expanded to CRCRLF, but retained as is. Optionally, 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).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] buf  
      private int cnt  
      private boolean detectBinary  
      private java.io.InputStream in  
      private boolean isBinary  
      private byte last  
      private int ptr  
      private byte[] single  
    • Constructor Summary

      Constructors 
      Constructor Description
      AutoCRLFInputStream​(java.io.InputStream in, boolean detectBinary)
      Creates a new InputStream, wrapping the specified stream
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      private boolean fillBuffer()  
      int read()
      int read​(byte[] bs, int off, int len)
      • Methods inherited from class java.io.InputStream

        available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

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

      • single

        private final byte[] single
      • buf

        private final byte[] buf
      • in

        private final java.io.InputStream in
      • cnt

        private int cnt
      • ptr

        private int ptr
      • isBinary

        private boolean isBinary
      • detectBinary

        private boolean detectBinary
      • last

        private byte last
    • Constructor Detail

      • AutoCRLFInputStream

        public AutoCRLFInputStream​(java.io.InputStream in,
                                   boolean detectBinary)
        Creates a new InputStream, wrapping the specified stream
        Parameters:
        in - raw input stream
        detectBinary - whether binaries should be detected
        Since:
        2.0
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] bs,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        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.InputStream
        Throws:
        java.io.IOException
      • fillBuffer

        private boolean fillBuffer()
                            throws java.io.IOException
        Throws:
        java.io.IOException