Package org.aksw.commons.io.input
Class ReadableChannels
java.lang.Object
org.aksw.commons.io.input.ReadableChannels
Also see
SeekableReadableChannels.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ReadableChannel<T>closeShield(ReadableChannel<T> in) static <A> ReadableChannel<A>concat(List<ReadableChannel<A>> channels) static <A> ReadableChannel<A>concat(ArrayOps<A> arrayOps, List<ReadableChannel<A>> channels) static <A> ReadableChannel<A>limit(ReadableChannel<A> dataStream, long limit) static <T> Iterator<T>newBoxedIterator(ReadableChannel<?> dataStream) static <T> CloseableIterator<T>newBoxedIterator(ReadableChannel<?> dataStream, int internalBufferSize) static <T> Stream<T>newBoxedStream(ReadableChannel<?> dataStream) static <T> Stream<T>newBoxedStream(ReadableChannel<?> dataStream, int internalBufferSize) static <A> ReadableChannel<A>newChannel(ReadableSource<A> source) static <T extends ReadableChannel<byte[]>>
ReadableByteChannelAdapter<T>newChannel(T dataStream) static InputStreamnewInputStream(ReadableChannel<byte[]> dataStream) static InputStreamnewInputStream(ReadableSource<byte[]> source) static <T> CloseableIterator<T>newIterator(ReadableChannel<T[]> dataStream) static <T> CloseableIterator<T>newIterator(ReadableChannel<T[]> dataStream, int internalBufferSize) static <T> Stream<T>newStream(ReadableChannel<T[]> dataStream) Wrap as a java8 stream.static <A> intreadFully(ReadableSource<A> channel, A array, int position, int length) static <A> longskip(ReadableChannel<A> channel, long req, A array, int position, int length) static <A,X extends ReadableChannel<A>>
ReadableChannelWithCounter<A,X> withCounter(X decoratee) static <A,T, X extends ReadableChannel<A>>
ReadableChannelWithValue<A,T, X> withValue(X decoratee, T value) static ReadableChannel<byte[]>wrap(InputStream inputStream) Note: The inputStream is internally wrapped with custom readable byte channel that does not close the input stream when a thread gets interrupted.static ReadableChannel<byte[]>wrap(ReadableByteChannel channel) Bridge to java.nio.static <T> ReadableChannel<T[]>static <T> ReadableChannel<T[]>
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
ReadableChannels
public ReadableChannels()
-
-
Method Details
-
limit
-
wrap
Bridge to java.nio. -
wrap
Note: The inputStream is internally wrapped with custom readable byte channel that does not close the input stream when a thread gets interrupted. This is essential when probing a seekable input stream for record offsets. Channels.newChannel does close streams on interrupt. -
wrap
-
wrap
public static <T> ReadableChannel<T[]> wrap(Iterator<T> iterator, Runnable closeAction, ArrayOps<T[]> arrayOps) -
newChannel
public static <T extends ReadableChannel<byte[]>> ReadableByteChannelAdapter<T> newChannel(T dataStream) -
newInputStream
-
newChannel
-
newInputStream
-
newIterator
-
newIterator
public static <T> CloseableIterator<T> newIterator(ReadableChannel<T[]> dataStream, int internalBufferSize) -
newStream
Wrap as a java8 stream. Closing the returned stream also closes the dataStream. -
newBoxedIterator
-
newBoxedIterator
public static <T> CloseableIterator<T> newBoxedIterator(ReadableChannel<?> dataStream, int internalBufferSize) -
newBoxedStream
-
newBoxedStream
-
withCounter
public static <A,X extends ReadableChannel<A>> ReadableChannelWithCounter<A,X> withCounter(X decoratee) -
withValue
public static <A,T, ReadableChannelWithValue<A,X extends ReadableChannel<A>> T, withValueX> (X decoratee, T value) -
concat
-
concat
public static <A> ReadableChannel<A> concat(ArrayOps<A> arrayOps, List<ReadableChannel<A>> channels) -
skip
public static <A> long skip(ReadableChannel<A> channel, long req, A array, int position, int length) throws IOException - Throws:
IOException
-
readFully
public static <A> int readFully(ReadableSource<A> channel, A array, int position, int length) throws IOException - Throws:
IOException
-
closeShield
-