io.netty.buffer.ByteBuf.writeCharSequence()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(397)

本文整理了Java中io.netty.buffer.ByteBuf.writeCharSequence()方法的一些代码示例,展示了ByteBuf.writeCharSequence()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.writeCharSequence()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:writeCharSequence

ByteBuf.writeCharSequence介绍

[英]Writes the specified CharSequence at the current writerIndex and increases the writerIndex by the written bytes. in this buffer.
[中]

代码示例

代码示例来源:origin: netty/netty

@Override
public void writeBytes(String s) throws IOException {
  buffer.writeCharSequence(s, CharsetUtil.US_ASCII);
}

代码示例来源:origin: netty/netty

@Override
public int writeCharSequence(CharSequence sequence, Charset charset) {
  return buf.writeCharSequence(sequence, charset);
}

代码示例来源:origin: netty/netty

@Override
public int writeCharSequence(CharSequence sequence, Charset charset) {
  return buf.writeCharSequence(sequence, charset);
}

代码示例来源:origin: redisson/redisson

@Override
public void writeBytes(String s) throws IOException {
  buffer.writeCharSequence(s, CharsetUtil.US_ASCII);
}

代码示例来源:origin: redisson/redisson

@Override
public int writeCharSequence(CharSequence sequence, Charset charset) {
  return buf.writeCharSequence(sequence, charset);
}

代码示例来源:origin: redisson/redisson

@Override
public int writeCharSequence(CharSequence sequence, Charset charset) {
  return buf.writeCharSequence(sequence, charset);
}

代码示例来源:origin: redisson/redisson

@Override
  public ByteBuf encode(Object in) throws IOException {
    ByteBuf out = ByteBufAllocator.DEFAULT.buffer();
    out.writeCharSequence(in.toString(), charset);
    return out;
  }
};

代码示例来源:origin: redisson/redisson

@Override
  public ByteBuf encode(Object in) throws IOException {
    ByteBuf out = ByteBufAllocator.DEFAULT.buffer();
    out.writeCharSequence(in.toString(), charset);
    return out;
  }
};

代码示例来源: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: 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: 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: 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: Netflix/zuul

@Override
public ChannelFuture sendPing(ChannelHandlerContext ctx) {
  final ByteBuf newBuff = ctx.alloc().buffer();
  newBuff.ensureWritable(SSE_PING.length());
  newBuff.writeCharSequence(SSE_PING, Charsets.UTF_8);
  return ctx.channel().writeAndFlush(newBuff);
}

代码示例来源:origin: wildfly/wildfly

private static ByteBuf newBinaryData(int statusCode, String reasonText) {
  if (reasonText == null) {
    reasonText = StringUtil.EMPTY_STRING;
  }
  ByteBuf binaryData = Unpooled.buffer(2 + reasonText.length());
  binaryData.writeShort(statusCode);
  if (!reasonText.isEmpty()) {
    binaryData.writeCharSequence(reasonText, CharsetUtil.UTF_8);
  }
  binaryData.readerIndex(0);
  return binaryData;
}

代码示例来源:origin: Netflix/zuul

@Override
public ChannelFuture sendPushMessage(ChannelHandlerContext ctx, ByteBuf mesg) {
  final ByteBuf newBuff = ctx.alloc().buffer();
  newBuff.ensureWritable(SSE_PREAMBLE.length());
  newBuff.writeCharSequence(SSE_PREAMBLE, Charsets.UTF_8);
  newBuff.ensureWritable(mesg.writableBytes());
  newBuff.writeBytes(mesg);
  newBuff.ensureWritable(SSE_TERMINATION.length());
  newBuff.writeCharSequence(SSE_TERMINATION, Charsets.UTF_8);
  mesg.release();
  return ctx.channel().writeAndFlush(newBuff);
}

代码示例来源:origin: wildfly/wildfly

void encode(ByteBuf buf) {
    if (bytes == null) {
      ByteBufUtil.copy(codeAsText, buf);
      buf.writeByte(SP);
      buf.writeCharSequence(reasonPhrase, CharsetUtil.US_ASCII);
    } else {
      buf.writeBytes(bytes);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Deprecated
public static void encodeAscii(CharSequence seq, ByteBuf buf) {
  if (seq instanceof AsciiString) {
    ByteBufUtil.copy((AsciiString) seq, 0, buf, seq.length());
  } else {
    buf.writeCharSequence(seq, CharsetUtil.US_ASCII);
  }
}

代码示例来源:origin: wildfly/wildfly

private static ByteBuf encodeFrame(StompHeadersSubframe frame, ChannelHandlerContext ctx) {
    ByteBuf buf = ctx.alloc().buffer();

    buf.writeCharSequence(frame.command().toString(), CharsetUtil.US_ASCII);
    buf.writeByte(StompConstants.LF);
    AsciiHeadersEncoder headersEncoder = new AsciiHeadersEncoder(buf, SeparatorType.COLON, NewlineType.LF);
    for (Entry<CharSequence, CharSequence> entry : frame.headers()) {
      headersEncoder.encode(entry);
    }
    buf.writeByte(StompConstants.LF);
    return buf;
  }
}

代码示例来源:origin: Netflix/zuul

@Override
public ChannelFuture sendPing(ChannelHandlerContext ctx) {
  final ByteBuf newBuff = ctx.alloc().buffer();
  newBuff.ensureWritable(SSE_PING.length());
  newBuff.writeCharSequence(SSE_PING, Charsets.UTF_8);
  return ctx.channel().writeAndFlush(newBuff);
}

代码示例来源:origin: Netflix/zuul

@Override
public ChannelFuture sendPushMessage(ChannelHandlerContext ctx, ByteBuf mesg) {
  final ByteBuf newBuff = ctx.alloc().buffer();
  newBuff.ensureWritable(SSE_PREAMBLE.length());
  newBuff.writeCharSequence(SSE_PREAMBLE, Charsets.UTF_8);
  newBuff.ensureWritable(mesg.writableBytes());
  newBuff.writeBytes(mesg);
  newBuff.ensureWritable(SSE_TERMINATION.length());
  newBuff.writeCharSequence(SSE_TERMINATION, Charsets.UTF_8);
  mesg.release();
  return ctx.channel().writeAndFlush(newBuff);
}

相关文章

ByteBuf类方法