org.kohsuke.stapler.framework.io.ByteBuffer.write()方法的使用及代码示例

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

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

ByteBuffer.write介绍

[英]Writes the contents of this buffer to another OutputStream.
[中]将此缓冲区的内容写入另一个OutputStream。

代码示例

代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder

@Nonnull
public AnnotatedLargeText<FolderComputation<I>> getEventsText() {
  File eventsFile = getEventsFile();
  if (eventsFile.length() <= 0) {
    ByteBuffer buffer = new ByteBuffer();
    try {
      buffer.write(
          String.format("No events as of %tc, waiting for events...%n", new Date())
              .getBytes(Charsets.UTF_8)
      );
      return new AnnotatedLargeText<FolderComputation<I>>(buffer, Charsets.UTF_8, false, this);
    } catch (IOException e) {
      // ignore and fall through
    }
  }
  return new AnnotatedLargeText<FolderComputation<I>>(eventsFile, Charsets.UTF_8, false, this);
}

代码示例来源:origin: jenkinsci/cloudbees-folder-plugin

@Nonnull
public AnnotatedLargeText<FolderComputation<I>> getEventsText() {
  File eventsFile = getEventsFile();
  if (eventsFile.length() <= 0) {
    ByteBuffer buffer = new ByteBuffer();
    try {
      buffer.write(
          String.format("No events as of %tc, waiting for events...%n", new Date())
              .getBytes(Charsets.UTF_8)
      );
      return new AnnotatedLargeText<FolderComputation<I>>(buffer, Charsets.UTF_8, false, this);
    } catch (IOException e) {
      // ignore and fall through
    }
  }
  return new AnnotatedLargeText<FolderComputation<I>>(eventsFile, Charsets.UTF_8, false, this);
}

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

String tail(String text, long start) throws IOException {
  LargeText t;
  try (ByteBuffer bb = new ByteBuffer()) {
    bb.write(text.getBytes(), 0, text.length());
    t = new LargeText(bb, true);
  }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  assertEquals(text.length(), t.writeLogTo(start, baos));
  return baos.toString();
}

相关文章