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

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

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

Bytes.toString介绍

[英]Creates a string from the position to the limit, The buffer is not modified by this call
[中]创建从位置到限制的字符串,此调用不会修改缓冲区

代码示例

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

/**
 * Creates a string from the {@code position} to the {@code limit}, The buffer is not modified
 * by this call
 *
 * @param buffer the buffer to use
 * @return a string contain the text from the {@code position}  to the  {@code limit}
 */
static String toString(@NotNull final Bytes<?> buffer) throws BufferUnderflowException {
  return toString(buffer, Integer.MAX_VALUE - 4);
}

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

private void logYamlToStandardOut(@NotNull WireIn in) {
  if (YamlLogging.showServerReads()) {
    try {
      LOG.info("\nServer Receives:\n" +
          Wires.fromSizePrefixedBlobs(in));
    } catch (Exception e) {
      LOG.info("\n\n" +
          Bytes.toString(in.bytes()));
    }
  }
}

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

private void logToBuffer(@NotNull WireIn in, @NotNull StringBuilder logBuffer, long start) {
  if (YamlLogging.showServerReads()) {
    logBuffer.setLength(0);
    try {
      logBuffer.append("\nServer Receives:\n")
          .append(Wires.fromSizePrefixedBlobs(in.bytes(), start));
    } catch (Exception e) {
      logBuffer.append("\n\n").append(Bytes.toString(in.bytes(), start, in.bytes().readLimit() - start));
    }
  }
}

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

public static <ACS extends Appendable & CharSequence> void append(ACS a, CharSequence cs, long start, long len) {
  if (a instanceof StringBuilder) {
    if (cs instanceof Bytes)
      ((StringBuilder) a).append(Bytes.toString(((Bytes) cs), start, len));
    else
      ((StringBuilder) a).append(cs.subSequence(Maths.toInt32(start), Maths.toInt32(len)));
  } else if (a instanceof Bytes) {
    ((Bytes) a).appendUtf8(cs, Maths.toInt32(start), Maths.toInt32(len));
  } else {
    throw new UnsupportedOperationException();
  }
}

相关文章

微信公众号

最新文章

更多