本文整理了Java中org.apache.jackrabbit.oak.commons.IOUtils.writeVarInt()
方法的一些代码示例,展示了IOUtils.writeVarInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.writeVarInt()
方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.commons.IOUtils
类名称:IOUtils
方法名:writeVarInt
[英]Write a variable size integer. Negative values need 5 bytes.
[中]写一个可变大小的整数。负值需要5个字节。
代码示例来源:origin: org.apache.jackrabbit/oak-commons
/**
* Write a byte array. This will first write the length as 4 bytes, and then
* the actual bytes.
*
* @param out the data output stream
* @param data the byte array
* @throws IOException if an IO exception occurred while writing.
*/
public static void writeBytes(OutputStream out, byte[] data) throws IOException {
writeVarInt(out, data.length);
out.write(data);
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Write a byte array. This will first write the length as 4 bytes, and then
* the actual bytes.
*
* @param out the data output stream
* @param data the byte array
* @throws IOException if an IO exception occurred while writing.
*/
public static void writeBytes(OutputStream out, byte[] data) throws IOException {
writeVarInt(out, data.length);
out.write(data);
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
/**
* Write a byte array. This will first write the length as 4 bytes, and then
* the actual bytes.
*
* @param out the data output stream
* @param data the byte array
* @throws IOException if an IO exception occurred while writing.
*/
public static void writeBytes(OutputStream out, byte[] data) throws IOException {
writeVarInt(out, data.length);
out.write(data);
}
代码示例来源:origin: org.apache.jackrabbit/oak-mk
@Override
public void write(String key, int value) throws Exception {
if (out == null) {
throw new IllegalStateException("no OutputStream provided");
}
IOUtils.writeVarInt(out, value);
}
代码示例来源:origin: org.apache.jackrabbit/oak-blob
IOUtils.writeVarInt(idStream, 0);
IOUtils.writeVarLong(idStream, length);
byte[] digest = messageDigest.digest();
IOUtils.writeVarInt(idStream, digest.length);
idStream.write(digest);
byte[] id = idStream.toByteArray();
代码示例来源:origin: apache/jackrabbit-oak
IOUtils.writeVarInt(idStream, 0);
IOUtils.writeVarLong(idStream, length);
byte[] digest = messageDigest.digest();
IOUtils.writeVarInt(idStream, digest.length);
idStream.write(digest);
byte[] id = idStream.toByteArray();
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
IOUtils.writeVarInt(idStream, 0);
IOUtils.writeVarLong(idStream, length);
byte[] digest = messageDigest.digest();
IOUtils.writeVarInt(idStream, digest.length);
idStream.write(digest);
byte[] id = idStream.toByteArray();
代码示例来源:origin: apache/jackrabbit-oak
} else if (blockLen < blockSizeMin) {
idStream.write(TYPE_DATA);
IOUtils.writeVarInt(idStream, blockLen);
idStream.write(block, 0, blockLen);
totalLength += blockLen;
byte[] digest = messageDigest.digest();
idStream.write(TYPE_HASH);
IOUtils.writeVarInt(idStream, level);
if (level > 0) {
IOUtils.writeVarInt(idStream, digest.length);
idStream.write(digest);
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
} else if (blockLen < blockSizeMin) {
idStream.write(TYPE_DATA);
IOUtils.writeVarInt(idStream, blockLen);
idStream.write(block, 0, blockLen);
totalLength += blockLen;
byte[] digest = messageDigest.digest();
idStream.write(TYPE_HASH);
IOUtils.writeVarInt(idStream, level);
if (level > 0) {
IOUtils.writeVarInt(idStream, digest.length);
idStream.write(digest);
代码示例来源:origin: org.apache.jackrabbit/oak-blob
} else if (blockLen < blockSizeMin) {
idStream.write(TYPE_DATA);
IOUtils.writeVarInt(idStream, blockLen);
idStream.write(block, 0, blockLen);
totalLength += blockLen;
byte[] digest = messageDigest.digest();
idStream.write(TYPE_HASH);
IOUtils.writeVarInt(idStream, level);
if (level > 0) {
IOUtils.writeVarInt(idStream, digest.length);
idStream.write(digest);
代码示例来源:origin: org.apache.jackrabbit/oak-mk
@Override
public void writeMap(String key, int count, StringEntryIterator iterator) throws Exception {
if (out == null) {
throw new IllegalStateException("no OutputStream provided");
}
IOUtils.writeVarInt(out, count);
while (iterator.hasNext()) {
StringEntry entry = iterator.next();
IOUtils.writeString(out, entry.getKey());
IOUtils.writeString(out, entry.getValue());
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-mk
@Override
public void writeMap(String key, int count, BytesEntryIterator iterator) throws Exception {
if (out == null) {
throw new IllegalStateException("no OutputStream provided");
}
IOUtils.writeVarInt(out, count);
while (iterator.hasNext()) {
BytesEntry entry = iterator.next();
IOUtils.writeString(out, entry.getKey());
IOUtils.writeBytes(out, entry.getValue());
}
}
代码示例来源:origin: apache/jackrabbit-oak
private static void testVarInt(int x, int expectedLen) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.writeVarInt(out, x);
byte[] data = out.toByteArray();
assertTrue(data.length <= 5);
if (expectedLen > 0) {
assertEquals(expectedLen, data.length);
}
ByteArrayInputStream in = new ByteArrayInputStream(data);
int x2 = IOUtils.readVarInt(in);
assertEquals(x, x2);
assertEquals(-1, in.read());
}
内容来源于网络,如有侵权,请联系作者删除!