本文整理汇总了Java中sun.nio.ch.ChannelInputStream类的典型用法代码示例。如果您正苦于以下问题:Java ChannelInputStream类的具体用法?Java ChannelInputStream怎么用?Java ChannelInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelInputStream类属于sun.nio.ch包,在下文中一共展示了ChannelInputStream类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeReader
import sun.nio.ch.ChannelInputStream; //导入依赖的package包/类
private void initializeReader() throws FileNotFoundException {
if (inputFile == null) {
throw new IllegalStateException("Can't initialize reader while input file is null");
}
buf = new BufferedReader(new InputStreamReader(new ChannelInputStream((new RandomAccessFile(inputFile, "r")).getChannel())));
lineNumber = 0;
linesRead = 0;
}
示例2: newInputStream
import sun.nio.ch.ChannelInputStream; //导入依赖的package包/类
/**
* Constructs a stream that reads bytes from the given channel.
*
* <p> The <tt>read</tt> methods of the resulting stream will throw an
* {@link IllegalBlockingModeException} if invoked while the underlying
* channel is in non-blocking mode. The stream will not be buffered, and
* it will not support the {@link InputStream#mark mark} or {@link
* InputStream#reset reset} methods. The stream will be safe for access by
* multiple concurrent threads. Closing the stream will in turn cause the
* channel to be closed. </p>
*
* @param ch
* The channel from which bytes will be read
*
* @return A new input stream
*/
public static InputStream newInputStream(ReadableByteChannel ch) {
checkNotNull(ch, "ch");
return new sun.nio.ch.ChannelInputStream(ch);
}
示例3: newInputStream
import sun.nio.ch.ChannelInputStream; //导入依赖的package包/类
/**
* Constructs a stream that reads bytes from the given channel.
*
* <p> The {@code read} methods of the resulting stream will throw an
* {@link IllegalBlockingModeException} if invoked while the underlying
* channel is in non-blocking mode. The stream will not be buffered, and
* it will not support the {@link InputStream#mark mark} or {@link
* InputStream#reset reset} methods. The stream will be safe for access by
* multiple concurrent threads. Closing the stream will in turn cause the
* channel to be closed. </p>
*
* @param ch
* The channel from which bytes will be read
*
* @return A new input stream
*/
public static InputStream newInputStream(ReadableByteChannel ch) {
Objects.requireNonNull(ch, "ch");
return new ChannelInputStream(ch);
}
示例4: newInputStream
import sun.nio.ch.ChannelInputStream; //导入依赖的package包/类
/**
* Constructs a stream that reads bytes from the given channel.
*
* <p> The <tt>read</tt> methods of the resulting stream will throw an
* {@link IllegalBlockingModeException} if invoked while the underlying
* channel is in non-blocking mode. The stream will not be buffered, and
* it will not support the {@link InputStream#mark mark} or {@link
* InputStream#reset reset} methods. The stream will be safe for access by
* multiple concurrent threads. Closing the stream will in turn cause the
* channel to be closed. </p>
*
* @param ch
* The channel from which bytes will be read
*
* @return A new input stream
*/
public static InputStream newInputStream(ReadableByteChannel ch) {
return new sun.nio.ch.ChannelInputStream(ch);
}