本文整理了Java中java.nio.channels.FileChannel.isOpen()
方法的一些代码示例,展示了FileChannel.isOpen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileChannel.isOpen()
方法的具体详情如下:
包路径:java.nio.channels.FileChannel
类名称:FileChannel
方法名:isOpen
暂无
代码示例来源:origin: apache/incubator-druid
@Override
public boolean isOpen()
{
return ch.isOpen();
}
}
代码示例来源:origin: redisson/redisson
@Override
public boolean isEndOfInput() throws Exception {
return !(offset < endOffset && in.isOpen());
}
代码示例来源:origin: neo4j/neo4j
@Override
public boolean isOpen()
{
return channel.isOpen();
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean isEndOfInput() throws Exception {
return !(offset < endOffset && in.isOpen());
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean isWriteShutdown() {
return !fileChannel.isOpen();
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public void close() throws IOException {
if(channel.isOpen()) {
if (forceOnClose) {
channel.force(true);
}
channel.close();
}
}
}
代码示例来源:origin: redisson/redisson
@Override
public boolean isEndOfInput() throws Exception {
return !(offset < endOffset && file.getChannel().isOpen());
}
代码示例来源:origin: square/okio
@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) {
long written = channel.transferFrom(source, position, remaining);
position += written;
remaining -= written;
}
}
代码示例来源:origin: redisson/redisson
public void run() {
if (address == 0)
return;
try {
unmap0(address, size);
address = 0;
if (channel.isOpen()) {
channel.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: square/okio
@Override public long read(Buffer sink, long byteCount) throws IOException {
if (!channel.isOpen()) throw new IllegalStateException("closed");
if (position == channel.size()) return -1L;
long read = channel.transferTo(position, byteCount, sink);
position += read;
return read;
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean isEndOfInput() throws Exception {
return !(offset < endOffset && file.getChannel().isOpen());
}
代码示例来源:origin: wildfly/wildfly
/**
* @throws FileNotFoundException
*/
public void checkOpen() throws FileNotFoundException {
if (cachedFile != null || !cachedChannel.isOpen()) {
cachedRAFile = new RandomAccessFile(cachedFile, "rw");
cachedChannel = cachedRAFile.getChannel();
}
}
代码示例来源:origin: spotify/docker-client
@Override
public synchronized int getReceiveBufferSize() throws SocketException {
if (!channel.isOpen()) {
throw new SocketException("Socket is closed");
}
throw new UnsupportedOperationException("Getting the receive buffer size is not supported");
}
代码示例来源:origin: atomix/atomix
@Override
public void flush() {
try {
if (channel.isOpen()) {
channel.force(true);
}
} catch (IOException e) {
throw new StorageException(e);
}
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
protected long transferContentTo(WritableByteChannel target) throws IOException {
// WARN: don't use channel.position(), it's always 0 here
// from FileChannel javadoc: "This method does not modify this channel's
// position."
long transferred = getChannel().transferTo(position, BodyChunkedInput.DEFAULT_CHUNK_SIZE, target);
if (transferred > 0) {
position += transferred;
}
if (position == length || transferred < 0) {
state = MultipartState.POST_CONTENT;
if (channel.isOpen()) {
channel.close();
}
} else {
slowTarget = true;
}
return transferred;
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
protected long transferContentTo(ByteBuf target) throws IOException {
// can return -1 if file is empty or FileChannel was closed
int transferred = target.writeBytes(getChannel(), target.writableBytes());
if (transferred > 0) {
position += transferred;
}
if (position == length || transferred < 0) {
state = MultipartState.POST_CONTENT;
if (channel.isOpen()) {
channel.close();
}
}
return transferred;
}
代码示例来源:origin: robovm/robovm
public void release() throws IOException {
if (!channel().isOpen()) {
throw new ClosedChannelException();
}
if (!isReleased) {
((FileChannelImpl) channel()).release(this);
isReleased = true;
}
}
}
代码示例来源:origin: apache/flink
@Test
public void testCleanup() {
try {
ByteBuffer data = ByteBuffer.allocate(157);
data.order(ByteOrder.LITTLE_ENDIAN);
FileUtils.writeCompletely(fileChannel, data);
fileChannel.position(54);
SpilledBufferOrEventSequence seq = new SpilledBufferOrEventSequence(tempFile, fileChannel, buffer, pageSize);
seq.open();
seq.cleanup();
assertFalse(fileChannel.isOpen());
assertFalse(tempFile.exists());
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
代码示例来源:origin: apache/flink
@After
public void cleanupSpiller() throws IOException {
if (spiller != null) {
spiller.close();
assertFalse(spiller.getCurrentChannel().isOpen());
assertFalse(spiller.getCurrentSpillFile().exists());
}
checkNoTempFilesRemain();
}
代码示例来源:origin: real-logic/agrona
@Test
public void shouldNotCloseChannelUponBufferClose()
{
buffer = new MappedResizeableBuffer(channel, 0, SIZE);
buffer.close();
assertTrue(channel.isOpen());
buffer = null;
}
内容来源于网络,如有侵权,请联系作者删除!