org.apache.jackrabbit.oak.commons.IOUtils.writeLong()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.2k)|赞(0)|评价(0)|浏览(114)

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

IOUtils.writeLong介绍

[英]Write a long (8 bytes).
[中]写一个长的(8字节)。

代码示例

代码示例来源:origin: apache/jackrabbit-oak

@Override
  public void call() throws Exception {
    int i = id.getAndIncrement();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtils.writeLong(out, i);
    out.write(EMPTY);
    byte[] data = out.toByteArray();
    String id = store.writeBlob(new ByteArrayInputStream(data));
    Assert.assertEquals(58, store.getBlobLength(id));
    byte[] test = out.toByteArray();
    Assert.assertEquals(8, store.readBlob(id, 0, test, 0, 8));
    Assert.assertTrue(Arrays.equals(data, test));
  }
});

代码示例来源:origin: apache/jackrabbit-oak

private static void testLong(long x) throws IOException {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  IOUtils.writeLong(out, x);
  byte[] data = out.toByteArray();
  assertTrue(data.length == Long.BYTES);
  ByteArrayInputStream in = new ByteArrayInputStream(data);
  long x2 = IOUtils.readLong(in);
  assertEquals(x, x2);
  assertEquals(-1, in.read());
}

相关文章