Package com.yahoo.jdisc.handler
Class UnsafeContentInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.yahoo.jdisc.handler.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 callclose()
before discarding it. Failure to do so will prevent the Container from ever shutting down.- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Constructor Description UnsafeContentInputStream(ReadableContentChannel content)
Constructs a new ContentInputStream that reads from the givenReadableContentChannel
.
-
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()
-
-
-
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 classjava.io.InputStream
-
read
public int read(byte[] buf, int off, int len)
- Overrides:
read
in classjava.io.InputStream
-
available
public int available()
- Overrides:
available
in classjava.io.InputStream
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
-