net.openhft.chronicle.bytes.Bytes.from()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(251)

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

Bytes.from介绍

[英]Convert text to bytes using ISO-8859-1 encoding and return a Bytes ready for reading.
[中]使用ISO-8859-1编码将文本转换为字节,并返回准备读取的字节。

代码示例

代码示例来源:origin: OpenHFT/Chronicle-Queue

@Test
public void testCheckIndexWithWriteBytes() {
  doTestCheckIndex(
      (appender, n) -> appender.writeBytes(Bytes.from("Message-" + n)));
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

appender.writeBytes(0x421d00000000L, Bytes.from("hellooooo world"));
  fail();
} catch (IllegalStateException e) {

代码示例来源:origin: net.openhft/saxophone

private Bytes finishSpace() {
  if (finishSpace == null) {
    finishSpace = Bytes.from(" ");
  }
  finishSpace.readPosition(0);
  return finishSpace;
}

代码示例来源:origin: net.openhft/chronicle-engine

@NotNull
public RequestContext queryString(@NotNull String queryString) {
  if (queryString.isEmpty())
    return this;
  @NotNull WireParser<Void> parser = getWireParser();
  Bytes bytes = Bytes.from(queryString);
  @NotNull QueryWire wire = new QueryWire(bytes);
  while (bytes.readRemaining() > 0)
    parser.parseOne(wire, null);
  return this;
}

代码示例来源:origin: net.openhft/chronicle-bytes

@org.jetbrains.annotations.NotNull
public static Bytes fromHexString(@org.jetbrains.annotations.NotNull String s) {
  try {
    Bytes in = Bytes.from(s);
    Bytes out = Bytes.elasticByteBuffer();
    OUTER:
    while (in.readRemaining() > 0) {
      in.parseHexLong();
      for (int i = 0; i < 16; i++) {
        if (in.peekUnsignedByte() == ' ') {
          in.readSkip(1);
          if (in.peekUnsignedByte() == ' ')
            break OUTER;
        }
        long value = in.parseHexLong();
        out.writeByte((byte) value);
      }
      if (in.readByte(in.readPosition() - 1) <= ' ')
        in.readSkip(-1);
      in.skipTo(StopCharTesters.CONTROL_STOP);
    }
    return out;
  } catch (BufferUnderflowException | BufferOverflowException e) {
    throw new AssertionError(e);
  }
}

相关文章

微信公众号

最新文章

更多