Module com.github.akurilov.commons
Class InputStreamWrapperChannel
- java.lang.Object
-
- com.github.akurilov.commons.io.util.BufferedByteChannelBase
-
- com.github.akurilov.commons.io.util.InputStreamWrapperChannel
-
- All Implemented Interfaces:
BufferedByteChannel,BufferedReadableByteChannel,java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.ReadableByteChannel
public class InputStreamWrapperChannel extends BufferedByteChannelBase implements BufferedReadableByteChannel
-
-
Field Summary
-
Fields inherited from class com.github.akurilov.commons.io.util.BufferedByteChannelBase
bb, buffer, REUSABLE_BUFF_SIZE_MAX, REUSABLE_BUFF_SIZE_MIN
-
-
Constructor Summary
Constructors Constructor Description InputStreamWrapperChannel(int buffSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static BufferedReadableByteChannelgetThreadLocalInstance(java.io.InputStream in, long remainingSize)Wraps the given input stream into the special stateless and reusable (thread local) byte channelintread(java.nio.ByteBuffer dst)-
Methods inherited from class com.github.akurilov.commons.io.util.BufferedByteChannelBase
buffer, isOpen
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.akurilov.commons.io.util.BufferedByteChannel
buffer
-
-
-
-
Method Detail
-
read
public final int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Throws:
java.io.IOException
-
getThreadLocalInstance
public static BufferedReadableByteChannel getThreadLocalInstance(java.io.InputStream in, long remainingSize) throws java.lang.IllegalStateException
Wraps the given input stream into the special stateless and reusable (thread local) byte channel- Parameters:
in- the input stream to wrapremainingSize- the estimated size of the data to be read from the given input- Returns:
- readable byte channel
- Throws:
java.lang.IllegalStateException- if negative remaining size is specified
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-