本文整理了Java中org.apache.jackrabbit.oak.commons.IOUtils.writeBytes()
方法的一些代码示例,展示了IOUtils.writeBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.writeBytes()
方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.commons.IOUtils
类名称:IOUtils
方法名:writeBytes
[英]Write a byte array. This will first write the length as 4 bytes, and then the actual bytes.
[中]写一个字节数组。这将首先将长度写入4字节,然后写入实际字节。
代码示例来源:origin: org.apache.jackrabbit/oak-mk
@Override
public void write(String key, byte[] value) throws Exception {
if (out == null) {
throw new IllegalStateException("no OutputStream provided");
}
IOUtils.writeBytes(out, value);
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Write a String. This will first write the length as 4 bytes, and then the
* UTF-8 encoded string.
*
* @param out the data output stream
* @param s the string (maximum length about 2 GB)
* @throws IOException if an IO exception occurred while writing
*/
public static void writeString(OutputStream out, String s) throws IOException {
writeBytes(out, s.getBytes("UTF-8"));
}
代码示例来源:origin: org.apache.jackrabbit/oak-commons
/**
* Write a String. This will first write the length as 4 bytes, and then the
* UTF-8 encoded string.
*
* @param out the data output stream
* @param s the string (maximum length about 2 GB)
* @throws IOException if an IO exception occurred while writing
*/
public static void writeString(OutputStream out, String s) throws IOException {
writeBytes(out, s.getBytes("UTF-8"));
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
/**
* Write a String. This will first write the length as 4 bytes, and then the
* UTF-8 encoded string.
*
* @param out the data output stream
* @param s the string (maximum length about 2 GB)
* @throws IOException if an IO exception occurred while writing
*/
public static void writeString(OutputStream out, String s) throws IOException {
writeBytes(out, s.getBytes("UTF-8"));
}
代码示例来源:origin: apache/jackrabbit-oak
assert coreProperties.createNewFile();
FileOutputStream out = new FileOutputStream(coreProperties);
IOUtils.writeBytes(out, ("name=" + coreName).getBytes("UTF-8"));
out.flush();
out.close();
代码示例来源:origin: org.apache.jackrabbit/oak-solr-core
assert coreProperties.createNewFile();
FileOutputStream out = new FileOutputStream(coreProperties);
IOUtils.writeBytes(out, ("name=" + coreName).getBytes("UTF-8"));
out.flush();
out.close();
代码示例来源:origin: apache/jackrabbit-oak
public void testBytesReadWrite() throws IOException {
final Random r = new Random();
int iterations = 1000;
while (iterations-- > 0) {
int n = Math.abs(r.nextInt()) % 0x40000;
byte[] buf = new byte[n];
r.nextBytes(buf);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.writeBytes(out, buf);
byte[] buf1 = IOUtils.readBytes(new ByteArrayInputStream(out.toByteArray()));
assertEquals(buf, buf1);
}
}
代码示例来源: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());
}
}
内容来源于网络,如有侵权,请联系作者删除!