java.nio.channels.GatheringByteChannel#write()源码实例Demo

下面列出了java.nio.channels.GatheringByteChannel#write() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    checkIndex(index, length);
    if (length == 0) {
        return 0;
    }

    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = memory.duplicate();
    }
    index = idx(index);
    tmpBuf.clear().position(index).limit(index + length);
    return out.write(tmpBuf);
}
 
源代码2 项目: Flink-CEPplus   文件: NetworkBuffer.java
@Override
public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
	// adapted from UnpooledDirectByteBuf:
	checkIndex(index, length);
	if (length == 0) {
		return 0;
	}

	ByteBuffer tmpBuf = memorySegment.wrap(index, length);
	return out.write(tmpBuf);
}
 
源代码3 项目: netty4.0.27Learn   文件: CompositeByteBuf.java
@Override
public int getBytes(int index, GatheringByteChannel out, int length)
        throws IOException {
    int count = nioBufferCount();
    if (count == 1) {
        return out.write(internalNioBuffer(index, length));
    } else {
        long writtenBytes = out.write(nioBuffers(index, length));
        if (writtenBytes > Integer.MAX_VALUE) {
            return Integer.MAX_VALUE;
        } else {
            return (int) writtenBytes;
        }
    }
}
 
源代码4 项目: netty-4.1.22   文件: FixedCompositeByteBuf.java
@Override
public int getBytes(int index, GatheringByteChannel out, int length)
        throws IOException {
    int count = nioBufferCount();
    if (count == 1) {
        return out.write(internalNioBuffer(index, length));
    } else {
        long writtenBytes = out.write(nioBuffers(index, length));
        if (writtenBytes > Integer.MAX_VALUE) {
            return Integer.MAX_VALUE;
        } else {
            return (int) writtenBytes;
        }
    }
}
 
源代码5 项目: netty-4.1.22   文件: UnpooledDirectByteBuf.java
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    ensureAccessible();
    if (length == 0) {
        return 0;
    }

    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = buffer.duplicate();
    }
    tmpBuf.clear().position(index).limit(index + length);
    return out.write(tmpBuf);
}
 
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    ensureAccessible();
    if (length == 0) {
        return 0;
    }

    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = buffer.duplicate();
    }
    tmpBuf.clear().position(index).limit(index + length);
    return out.write(tmpBuf);
}
 
源代码7 项目: netty-4.1.22   文件: UnpooledHeapByteBuf.java
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    ensureAccessible();
    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = ByteBuffer.wrap(array);
    }
    return out.write((ByteBuffer) tmpBuf.clear().position(index).limit(index + length));
}
 
源代码8 项目: netty-4.1.22   文件: CompositeByteBuf.java
@Override
public int getBytes(int index, GatheringByteChannel out, int length)
        throws IOException {
    int count = nioBufferCount();
    if (count == 1) {
        return out.write(internalNioBuffer(index, length));
    } else {
        long writtenBytes = out.write(nioBuffers(index, length));
        if (writtenBytes > Integer.MAX_VALUE) {
            return Integer.MAX_VALUE;
        } else {
            return (int) writtenBytes;
        }
    }
}
 
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    ensureAccessible();
    if (length == 0) {
        return 0;
    }

    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = buffer.duplicate();
    }
    tmpBuf.clear().position(index).limit(index + length);
    return out.write(tmpBuf);
}
 
源代码10 项目: netty-4.1.22   文件: ReadOnlyByteBufferBuf.java
@Override
public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
    ensureAccessible();
    if (length == 0) {
        return 0;
    }

    ByteBuffer tmpBuf = internalNioBuffer();
    tmpBuf.clear().position(index).limit(index + length);
    return out.write(tmpBuf);
}
 
源代码11 项目: netty4.0.27Learn   文件: UnpooledHeapByteBuf.java
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    ensureAccessible();
    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = ByteBuffer.wrap(array);
    }
    return out.write((ByteBuffer) tmpBuf.clear().position(index).limit(index + length));
}
 
源代码12 项目: qpid-broker-j   文件: QpidByteBufferFactory.java
static long write(GatheringByteChannel channel, Collection<QpidByteBuffer> qpidByteBuffers)
        throws IOException
{
    List<ByteBuffer> byteBuffers = new ArrayList<>();
    for (QpidByteBuffer qpidByteBuffer : qpidByteBuffers)
    {
        Collections.addAll(byteBuffers, getUnderlyingBuffers(qpidByteBuffer));
    }
    return channel.write(byteBuffers.toArray(new ByteBuffer[byteBuffers.size()]));
}
 
private int getBytes(int index, GatheringByteChannel out, int length, boolean internal) throws IOException {
    checkIndex(index, length);
    index = idx(index);
    ByteBuffer tmpBuf;
    if (internal) {
        tmpBuf = internalNioBuffer();
    } else {
        tmpBuf = ByteBuffer.wrap(array);
    }
    return out.write((ByteBuffer) tmpBuf.clear().position(index).limit(index + length));
}
 
源代码14 项目: qmq   文件: DataTransfer.java
@Override
public long transferTo(WritableByteChannel target, long position) throws IOException {
    GatheringByteChannel channel = (GatheringByteChannel) target;
    long write = channel.write(this.buffers);
    transferred += write;
    return write;
}
 
源代码15 项目: qmq   文件: PullMessageProcessor.java
@Override
public long transferTo(WritableByteChannel target, long position) throws IOException {
    GatheringByteChannel channel = (GatheringByteChannel) target;
    long write = channel.write(this.buffers);
    transferred += write;
    return write;
}
 
源代码16 项目: netty4.0.27Learn   文件: ReadOnlyByteBufferBuf.java
@Override
public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
    ensureAccessible();
    if (length == 0) {
        return 0;
    }

    ByteBuffer tmpBuf = internalNioBuffer();
    tmpBuf.clear().position(index).limit(index + length);
    return out.write(tmpBuf);
}
 
源代码17 项目: dubbox   文件: HeapChannelBuffer.java
public int getBytes(int index, GatheringByteChannel out, int length)
    throws IOException {
    return out.write(ByteBuffer.wrap(array, index, length));
}
 
@Override
public long writeTo(GatheringByteChannel channel) throws IOException {
  long bytes = channel.write(buffers.toArray(new ByteBuffer[0]));
  findCurrent();
  return bytes;
}
 
源代码19 项目: hadoop-ozone   文件: IncrementalChunkBuffer.java
@Override
public long writeTo(GatheringByteChannel channel) throws IOException {
  return channel.write(buffers.toArray(new ByteBuffer[0]));
}
 
源代码20 项目: dubbo3   文件: HeapChannelBuffer.java
public int getBytes(int index, GatheringByteChannel out, int length)
    throws IOException {
    return out.write(ByteBuffer.wrap(array, index, length));
}
 
 同类方法