Java Code Examples for java.nio.channels.ReadableByteChannel#isOpen()
The following examples show how to use
java.nio.channels.ReadableByteChannel#isOpen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileChannelImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 2
Source File: FileChannelImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 3
Source File: FileChannelImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 4
Source File: WindowedSeekableByteChannel.java From emissary with Apache License 2.0 | 6 votes |
/** * Creates a new instance and populates buffers with data. */ public WindowedSeekableByteChannel(final ReadableByteChannel in, final int buffsize) throws IOException { logger.debug("WindowSeekableByteChannel created with buffer size = {}", buffsize); if ((in == null) || !in.isOpen()) { throw new IllegalArgumentException("Channel must be open and not null:"); } this.in = in; int capacity = buffsize / 2; if ((buffsize % 2) == 1) { capacity++; } this.buff1 = ByteBuffer.allocate(capacity); readIntoBuffer(this.buff1); // only fill buff2 if there's more to read. otherwise save heap if (!this.endofchannel) { this.buff2 = ByteBuffer.allocate(capacity); readIntoBuffer(this.buff2); } else { this.buff2 = ByteBuffer.allocate(0); } }
Example 5
Source File: FileChannelImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 6
Source File: FileChannelImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 7
Source File: FileChannelImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 8
Source File: FileChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 9
Source File: FileChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 10
Source File: FileChannelImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 11
Source File: FileChannelImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 12
Source File: FileChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 13
Source File: FileChannelImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException { ensureOpen(); if (!src.isOpen()) throw new ClosedChannelException(); if (!writable) throw new NonWritableChannelException(); if ((position < 0) || (count < 0)) throw new IllegalArgumentException(); if (position > size()) return 0; if (src instanceof FileChannelImpl) return transferFromFileChannel((FileChannelImpl)src, position, count); return transferFromArbitraryChannel(src, position, count); }
Example 14
Source File: NioUtils.java From Mycat-Balance with Apache License 2.0 | 5 votes |
/** * 略过通道的所有数据 * * @param socketChannel */ public static int skipChannelData(ReadableByteChannel socketChannel) throws IOException { ByteBuffer buffer = ByteBuffer.allocate(1024); int allLength = 0; int length = 0; while (socketChannel.isOpen() && (length = socketChannel.read(buffer)) > 0) { allLength += length; buffer.clear(); } log.debug("skipped length [{}]", allLength); return allLength; }