@Override public boolean isOpen() { return channel.isOpen(); }
@Override public boolean isOpen() { return originalChannel.isOpen(); }
@Override public boolean isOpen() { if (!out.isOpen()) { closed.set(true); } return !closed.get(); }
@Override public boolean isOpen() { return getMeasured().isOpen(); }
@Override public boolean isOpen() { return mChannel.isOpen(); }
public boolean isOpen() { return !invalid && writeChannel.isOpen() && readChannel.isOpen(); }
@Override public void write(Buffer source, long byteCount) throws IOException { if (!channel.isOpen()) throw new IllegalStateException("closed"); if (byteCount == 0) return; long remaining = byteCount; while (remaining > 0) { timeout.throwIfReached(); try (Buffer.UnsafeCursor ignored = source.readUnsafe(cursor)) { cursor.seek(0); int length = (int) Math.min(cursor.end - cursor.start, remaining); int written = channel.write(ByteBuffer.wrap(cursor.data, cursor.start, length)); remaining -= written; source.skip(written); } } }
/** * Does some basic writes to {@code channel}. We execute this against both Okio's channels and * also a standard implementation from the JDK to confirm that their behavior is consistent. */ private void testWritableByteChannel(WritableByteChannel channel) throws Exception { assertTrue(channel.isOpen()); ByteBuffer byteBuffer = ByteBuffer.allocate(1024); byteBuffer.put("abcdefghijklmnopqrstuvwxyz".getBytes(Charsets.UTF_8)); byteBuffer.flip(); byteBuffer.position(3); byteBuffer.limit(23); int byteCount = channel.write(byteBuffer); assertEquals(20, byteCount); assertEquals(23, byteBuffer.position()); assertEquals(23, byteBuffer.limit()); channel.close(); assertEquals(channel instanceof Buffer, channel.isOpen()); // Buffer.close() does nothing. }
public long transferTo(long position, long count, WritableByteChannel target) throws IOException { checkOpen(); if (!target.isOpen()) { throw new ClosedChannelException();
public boolean isOpen() { return wrapped.isOpen(); } }
@Override public void close() throws IOException { try { flushBuffer(); super.close(); } finally { if (channel.isOpen()) { channel.close(); } } } }
while ((target.isOpen()) && (written < bytes.length)) { long nWrite = target.write(message); written += nWrite;
/** * Release resources associated with this writer. <B>Highly recommended</B> * * @throws IOException If errors occur. */ public void close() throws IOException { // IANS - GEOT 193, bogus 0x00 written. According to dbf spec, optional // eof 0x1a marker is, well, optional. Since the original code wrote a // 0x00 (which is wrong anyway) lets just do away with this :) // - produced dbf works in OpenOffice and ArcExplorer java, so it must // be okay. // buffer.position(0); // buffer.put((byte) 0).position(0).limit(1); // write(); if (channel != null && channel.isOpen()) { channel.close(); streamLogger.close(); } if (buffer != null) { NIOUtilities.clean(buffer, false); } buffer = null; channel = null; formatter = null; }
@Override public boolean isOpen() { for (WritableByteChannel writer : writers) { if (!writer.isOpen()) { return false; } } return true; }
/** * Flag indicating whether the underlying channel * is open. * * @return true if it is open, false otherwise */ public boolean isOpen() { return channel.isOpen(); } }
/** * {@inheritDoc} */ @Override public boolean isSendOpen() { return out.isOpen(); }
/** * Tells whether this channel is open. * * @return a value indicating whether this channel is open */ @Override public boolean isOpen() { return (pipeSinkChannel != null) && pipeSinkChannel.isOpen(); }
@Override public void close() throws IOException { if (!channel.isOpen()) { return; } channel.close(); }
@Override public void writeTo(OutputStream out) throws IOException { final WritableByteChannel outputChannel = Channels.newChannel(out); channel.linkChannel(outputChannel); while (channel.isOpen() && outputChannel.isOpen()) { try { Thread.sleep(50); } catch (InterruptedException e) { } } }