Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.writeBytes()


    @Override
    public ByteTransferBuffer next() {
      try {
        ByteBuf byteBuf = PooledByteBufAllocator.DEFAULT.buffer(FSDelegation.this.buffer);
        if (this.set(byteBuf.writeBytes(this.input, byteBuf.capacity())).get() > 0) {
          this.readable.addAndGet(current.get());
        }
        this.queue.add(this.byteBuf = byteBuf);
        FSDelegation.this.resourceCounter.increment(FSDelegation.this.chunk);
        return this;
View Full Code Here


public class OpenSSLKDFTest {

    @Test
    public void testGeneration() {
        ByteBuf password = Unpooled.buffer();
        password.writeBytes( "tacos".getBytes() );
        OpenSSLKDF kdf = new OpenSSLKDF(password, 64, 8);

        ByteBuf key = kdf.getKey();

        assertEquals(key.getByte(0) & 0xff, 0xda);
View Full Code Here

        this.channelFuture.channel().writeAndFlush(buf.retain());
    }

    public void writeUtf8String(String str) throws IOException {
        ByteBuf buf = this.channelFuture.channel().alloc().buffer();
        buf.writeBytes(str.getBytes("utf8"));
        write(buf);
    }

    public void writeAsciiString(String str) throws IOException {
        ByteBuf buf = this.channelFuture.channel().alloc().buffer();
View Full Code Here

        write(buf);
    }

    public void writeAsciiString(String str) throws IOException {
        ByteBuf buf = this.channelFuture.channel().alloc().buffer();
        buf.writeBytes(str.getBytes("us-ascii"));
        write(buf);
    }

}
View Full Code Here

                    buffer.position( position );
                }
                int fd = -1;
                buffer.limit(numRead);
                ByteBuf nettyBuf = alloc().buffer(numRead);
                nettyBuf.writeBytes(buffer);
                if (control.getType() == 0x01 && control.getLevel() == SocketLevel.SOL_SOCKET.intValue()) {
                    fd = control.getData().order(ByteOrder.nativeOrder()).getInt();
                }
                IPCRecord record = new IPCRecord(nettyBuf, fd);
                writeInbound(record);
View Full Code Here

        this.type = Type.INPUT;
    }

    public void writeUtf8String(String data, int fd) {
        ByteBuf buffer = this.channelFuture.channel().alloc().buffer();
        buffer.writeBytes(data.getBytes(StandardCharsets.UTF_8));
        this.channelFuture.channel().writeAndFlush(new IPCRecord(buffer, fd));
    }

    protected void openOutput(int fd, FileDescriptor fileDescriptor) throws IOException {
        FileOutputStream out = new FileOutputStream(fileDescriptor);
View Full Code Here

        int len = sourceEnd - sourceStart;

        len = Math.min( len, bufLen( target ) - targetStart );

        targetBuf.writeBytes(srcBuf, sourceStart, len);
        targetBuf.writerIndex(Math.max(targetBuf.writerIndex(), origWriter));

        return len;
    }
View Full Code Here

        ByteBuf b = extract( object );
        int origWriter = b.writerIndex();
        byte[] bytes = str.getBytes( UTF8 );
        b.writerIndex( offset );
        len = Math.min( bytes.length, Math.min( len, bufLen(object) - offset  ) );
        b.writeBytes( bytes, 0, len );
        b.writerIndex( Math.max( b.writerIndex(), origWriter ) );
        return new long[] { str.length(), len };
    }

    public static String utf8Slice(JSObject object, int start, int end) {
View Full Code Here

    public static long asciiWrite(JSObject object, String str, int offset, int len) {
        ByteBuf b = extract( object );
        int origWriter = b.writerIndex();
        byte[] bytes = str.getBytes( ASCII );
        len = Math.min( bytes.length, Math.min( len, b.writableBytes() ) );
        b.writeBytes( bytes, 0, len );
        b.writerIndex( Math.max( b.writerIndex(), origWriter ) );
        return len;
    }

    public static String asciiSlice(JSObject object, int start, int end) {
View Full Code Here

    public static long ucs2Write(JSObject object, String str, int offset, int len) {
        ByteBuf b = extract( object );
        int origWriter = b.writerIndex();
        byte[] bytes = str.getBytes( UCS2 );
        len = Math.min( bytes.length, Math.min( len, b.writableBytes() ) );
        b.writeBytes( bytes, 0, len );
        b.writerIndex( Math.max( b.writerIndex(), origWriter ) );
        return len;
    }

    public static String ucs2Slice(JSObject object, int start, int end) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.