Tabnine Logo
ByteBuf.writeBytes
Code IndexAdd Tabnine to your IDE (free)

How to use
writeBytes
method
in
io.netty.buffer.ByteBuf

Best Java code snippets using io.netty.buffer.ByteBuf.writeBytes (Showing top 20 results out of 5,337)

Refine searchRefine arrow

  • ByteBuf.readableBytes
  • ByteBuf.writeByte
  • ByteBuf.writeInt
  • ByteBufAllocator.buffer
  • ByteBuf.release
  • ByteBuf.writeShort
  • ByteBuf.readerIndex
origin: netty/netty

static ByteBuf expandCumulation(ByteBufAllocator alloc, ByteBuf cumulation, int readable) {
  ByteBuf oldCumulation = cumulation;
  cumulation = alloc.buffer(oldCumulation.readableBytes() + readable);
  cumulation.writeBytes(oldCumulation);
  oldCumulation.release();
  return cumulation;
}
origin: AsyncHttpClient/async-http-client

private ByteBuf lazyLoadContentBuffer() {
 if (contentBuffer == null) {
  contentBuffer = ByteBufAllocator.DEFAULT.buffer((int) getContentLength());
  contentBuffer.writeBytes(EXTRA_BYTES).writeBytes(boundary).writeBytes(EXTRA_BYTES).writeBytes(CRLF_BYTES);
 }
 return contentBuffer;
}
origin: redisson/redisson

private void writeArgument(ByteBuf out, byte[] arg) {
  out.writeByte(BYTES_PREFIX);
  out.writeCharSequence(Long.toString(arg.length), CharsetUtil.US_ASCII);
  out.writeBytes(CRLF);
  out.writeBytes(arg);
  out.writeBytes(CRLF);
}

origin: traccar/traccar

public static ByteBuf formatMessage(int type, ByteBuf id, ByteBuf data) {
  ByteBuf buf = Unpooled.buffer();
  buf.writeByte(0x7e);
  buf.writeShort(type);
  buf.writeShort(data.readableBytes());
  buf.writeBytes(id);
  buf.writeShort(1); // index
  buf.writeBytes(data);
  data.release();
  buf.writeByte(Checksum.xor(buf.nioBuffer(1, buf.readableBytes() - 1)));
  buf.writeByte(0x7e);
  return buf;
}
origin: redisson/redisson

private void writeArgument(ByteBuf out, ByteBuf arg) {
  out.writeByte(BYTES_PREFIX);
  out.writeCharSequence(Long.toString(arg.readableBytes()), CharsetUtil.US_ASCII);
  out.writeBytes(CRLF);
  out.writeBytes(arg, arg.readerIndex(), arg.readableBytes());
  out.writeBytes(CRLF);
}
origin: netty/netty

/**
 * Creates a new buffer whose content is a copy of the specified
 * {@code buffer}'s readable bytes.  The new buffer's {@code readerIndex}
 * and {@code writerIndex} are {@code 0} and {@code buffer.readableBytes}
 * respectively.
 */
public static ByteBuf copiedBuffer(ByteBuf buffer) {
  int readable = buffer.readableBytes();
  if (readable > 0) {
    ByteBuf copy = buffer(readable);
    copy.writeBytes(buffer, buffer.readerIndex(), readable);
    return copy;
  } else {
    return EMPTY_BUFFER;
  }
}
origin: GlowstoneMC/Glowstone

private void sendResponse(ChannelHandlerContext ctx, int requestId, int type, String payload) {
  ByteBuf buf = ctx.alloc().buffer().order(ByteOrder.LITTLE_ENDIAN);
  buf.writeInt(requestId);
  buf.writeInt(type);
  buf.writeBytes(payload.getBytes(StandardCharsets.UTF_8));
  buf.writeByte(0);
  buf.writeByte(0);
  ctx.write(buf);
}
origin: eclipse-vertx/vert.x

private void end(ChannelHandlerContext ctx, ByteBuf buf, boolean h2c) {
 if (current > 0) {
  ByteBuf msg = Unpooled.buffer(current + buf.readableBytes());
  msg.writeBytes(HTTP_2_PREFACE_ARRAY, 0, current);
  msg.writeBytes(buf);
  buf.release();
  buf = msg;
 }
 configure(ctx, h2c);
 ctx.pipeline().remove(this);
 ctx.fireChannelRead(buf);
}
origin: alibaba/Sentinel

private void encodeString(String param, ByteBuf target) {
  target.writeByte(ClusterConstants.PARAM_TYPE_STRING);
  byte[] tmpChars = param.getBytes();
  target.writeInt(tmpChars.length);
  target.writeBytes(tmpChars);
}
origin: netty/netty

checkNotNull(buf, "buf");
checkNotNull(charset, "charset");
final int maxIndex = buf.readerIndex() + buf.readableBytes();
if (index < 0 || length < 0 || index > maxIndex - length) {
  throw new IndexOutOfBoundsException("index: " + index + " length: " + length);
      ByteBuf heapBuffer = buf.alloc().heapBuffer(length);
      try {
        heapBuffer.writeBytes(buf, index, length);
        decoder.decode(heapBuffer.internalNioBuffer(heapBuffer.readerIndex(), length));
      } finally {
        heapBuffer.release();
origin: redisson/redisson

private Object[] copy(Object[] params) {
  List<Object> result = new ArrayList<Object>();
  for (Object object : params) {
    if (object instanceof ByteBuf) {
      ByteBuf b = ((ByteBuf) object);
      ByteBuf nb = ByteBufAllocator.DEFAULT.buffer(b.readableBytes());
      int ri = b.readerIndex();
      nb.writeBytes(b);
      b.readerIndex(ri);
      result.add(nb);
    } else {
      result.add(object);
    }
  }
  return result.toArray();
}

origin: redisson/redisson

private void encodeRawRecord(DnsRawRecord record, ByteBuf out) throws Exception {
  encodeRecord0(record, out);
  ByteBuf content = record.content();
  int contentLen = content.readableBytes();
  out.writeShort(contentLen);
  out.writeBytes(content, content.readerIndex(), contentLen);
}
origin: netty/netty

@Override
public ByteBuf copy(int index, int length) {
  checkIndex(index, length);
  boolean release = true;
  ByteBuf buf = alloc().buffer(length);
  try {
    buf.writeBytes(this, index, length);
    release = false;
    return buf;
  } finally {
    if (release) {
      buf.release();
    }
  }
}
origin: traccar/traccar

private ByteBuf encodeContent(String content) {
  ByteBuf buf = Unpooled.buffer();
  buf.writeShort(content.length() + 6);
  buf.writeShort(0); // index
  buf.writeByte(0x04); // command type
  buf.writeByte(0); // optional header
  buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII));
  return buf;
}
origin: AsyncHttpClient/async-http-client

protected long transfer(ByteBuf source, ByteBuf target, MultipartState sourceFullyWrittenState) {
 int sourceRemaining = source.readableBytes();
 int targetRemaining = target.writableBytes();
 if (sourceRemaining <= targetRemaining) {
  target.writeBytes(source);
  state = sourceFullyWrittenState;
  return sourceRemaining;
 } else {
  target.writeBytes(source, targetRemaining);
  return targetRemaining;
 }
}
origin: netty/netty

  out.writeBytes(STREAM_START);
int dataLength = in.readableBytes();
if (dataLength > MIN_COMPRESSIBLE_LENGTH) {
  for (;;) {
    out.writeInt(0);
    if (dataLength > Short.MAX_VALUE) {
      ByteBuf slice = in.readSlice(Short.MAX_VALUE);
origin: GlowstoneMC/Glowstone

  private ByteBuf responseToByteBuf(ChannelHandlerContext ctx, String string) {
    ByteBuf bytebuf = ctx.alloc().buffer(3 + string.length());

    bytebuf.writeByte(0xFF);
    bytebuf.writeShort(string.length());
    try {
      bytebuf.writeBytes(string.getBytes("UTF-16BE"));
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }

    return bytebuf;
  }
}
origin: atomix/atomix

@Override
public void broadcast(String subject, byte[] payload) {
 if (enabled) {
  Message message = new Message(subject, payload);
  byte[] bytes = SERIALIZER.encode(message);
  ByteBuf buf = serverChannel.alloc().buffer(4 + bytes.length);
  buf.writeInt(bytes.length).writeBytes(bytes);
  serverChannel.writeAndFlush(new DatagramPacket(buf, groupAddress));
 }
}
origin: traccar/traccar

private ByteBuf encodeContent(String content) {
  ByteBuf buf = Unpooled.buffer(12 + 56);
  buf.writeCharSequence("\r\n*KW", StandardCharsets.US_ASCII);
  buf.writeByte(0);
  buf.writeShortLE(buf.capacity());
  buf.writeShortLE(NoranProtocolDecoder.MSG_CONTROL);
  buf.writeInt(0); // gis ip
  buf.writeShortLE(0); // gis port
  buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII));
  buf.writerIndex(buf.writerIndex() + 50 - content.length());
  buf.writeCharSequence("\r\n", StandardCharsets.US_ASCII);
  return buf;
}
origin: mpusher/mpush

public void encodeBytes(ByteBuf body, byte[] field) {
  if (field == null || field.length == 0) {
    body.writeShort(0);
  } else if (field.length < Short.MAX_VALUE) {
    body.writeShort(field.length).writeBytes(field);
  } else {
    body.writeShort(Short.MAX_VALUE).writeInt(field.length - Short.MAX_VALUE).writeBytes(field);
  }
}
io.netty.bufferByteBufwriteBytes

Javadoc

Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes. This method is basically same with #writeBytes(ByteBuf,int,int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while #writeBytes(ByteBuf,int,int)does not.

Popular methods of ByteBuf

  • readableBytes
    Returns the number of readable bytes which is equal to (this.writerIndex - this.readerIndex).
  • readBytes
    Transfers this buffer's data to the specified destination starting at the current readerIndex and in
  • release
  • readerIndex
  • writeByte
    Sets the specified byte at the current writerIndexand increases the writerIndex by 1 in this buffer.
  • readByte
    Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
  • writeInt
    Sets the specified 32-bit integer at the current writerIndexand increases the writerIndex by 4 in th
  • readInt
    Gets a 32-bit integer at the current readerIndexand increases the readerIndex by 4 in this buffer.
  • toString
    Decodes this buffer's readable bytes into a string with the specified character set name. This metho
  • retain
  • writerIndex
    Sets the writerIndex of this buffer.
  • isReadable
    Returns true if and only if this buffer contains equal to or more than the specified number of eleme
  • writerIndex,
  • isReadable,
  • writeLong,
  • writeShort,
  • skipBytes,
  • readLong,
  • array,
  • nioBuffer,
  • resetReaderIndex

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • getContentResolver (Context)
  • putExtra (Intent)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • String (java.lang)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • JFrame (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now