Class ContentLengthInputStream

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

    public final class ContentLengthInputStream
    extends java.io.FilterInputStream
    Uses the content length as the basis for the return value of available() and verifies that at least content length bytes are returned from the various read methods.
    • Field Summary

      • Fields inherited from class java.io.FilterInputStream

        in
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      static java.io.InputStream obtain​(java.io.InputStream other, long contentLength)  
      static java.io.InputStream obtain​(java.io.InputStream other, java.lang.String contentLengthHeader)  
      int read()  
      int read​(byte[] buffer)  
      int read​(byte[] buffer, int byteOffset, int byteCount)  
      • Methods inherited from class java.io.FilterInputStream

        close, mark, markSupported, reset, skip
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

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

      • obtain

        @NonNull
        public static java.io.InputStream obtain​(@NonNull
                                                 java.io.InputStream other,
                                                 @Nullable
                                                 java.lang.String contentLengthHeader)
      • obtain

        @NonNull
        public static java.io.InputStream obtain​(@NonNull
                                                 java.io.InputStream other,
                                                 long contentLength)
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] buffer)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] buffer,
                        int byteOffset,
                        int byteCount)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException