Class UnsafeContentInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    ContentInputStream

    public class UnsafeContentInputStream
    extends java.io.InputStream

    This class provides an adapter from a ReadableContentChannel to an InputStream. This class supports all regular InputStream operations, and can be combined with any other InputStream API.

    Because this class encapsulates the reference-counted ContentChannel operations, one must be sure to always call close() before discarding it. Failure to do so will prevent the Container from ever shutting down.

    Author:
    Simon Thoresen Hult
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      void mark​(int readlimit)  
      boolean markSupported()  
      int read()  
      int read​(byte[] buf, int off, int len)  
      void reset()  
      • Methods inherited from class java.io.InputStream

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

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

      • UnsafeContentInputStream

        public UnsafeContentInputStream​(ReadableContentChannel content)

        Constructs a new ContentInputStream that reads from the given ReadableContentChannel.

        Parameters:
        content - The content to read the stream from.
    • Method Detail

      • read

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

        public int read​(byte[] buf,
                        int off,
                        int len)
        Overrides:
        read in class java.io.InputStream
      • available

        public int available()
        Overrides:
        available in class java.io.InputStream
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class java.io.InputStream
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.InputStream
        Throws:
        java.io.IOException
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.InputStream