本文整理了Java中org.apache.jackrabbit.oak.commons.IOUtils.skipFully()
方法的一些代码示例,展示了IOUtils.skipFully()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.skipFully()
方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.commons.IOUtils
类名称:IOUtils
方法名:skipFully
[英]Skip a number of bytes in an input stream.
[中]跳过输入流中的若干字节。
代码示例来源:origin: apache/jackrabbit-oak
@Override
protected byte[] readBlockFromBackend(BlockId id) throws IOException {
File f = getFile(id.digest, false);
if (!f.exists()) {
File old = getFile(id.digest, true);
f.getParentFile().mkdir();
old.renameTo(f);
f = getFile(id.digest, false);
}
int length = (int) Math.min(f.length(), getBlockSize());
byte[] data = new byte[length];
InputStream in = new FileInputStream(f);
try {
IOUtils.skipFully(in, id.pos);
IOUtils.readFully(in, data, 0, length);
} finally {
in.close();
}
return data;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override
protected byte[] readBlockFromBackend(BlockId id) throws IOException {
File f = getFile(id.digest, false);
if (!f.exists()) {
File old = getFile(id.digest, true);
f.getParentFile().mkdir();
old.renameTo(f);
f = getFile(id.digest, false);
}
int length = (int) Math.min(f.length(), getBlockSize());
byte[] data = new byte[length];
InputStream in = new FileInputStream(f);
try {
IOUtils.skipFully(in, id.pos);
IOUtils.readFully(in, data, 0, length);
} finally {
in.close();
}
return data;
}
代码示例来源:origin: org.apache.jackrabbit/oak-blob
@Override
protected byte[] readBlockFromBackend(BlockId id) throws IOException {
File f = getFile(id.digest, false);
if (!f.exists()) {
File old = getFile(id.digest, true);
f.getParentFile().mkdir();
old.renameTo(f);
f = getFile(id.digest, false);
}
int length = (int) Math.min(f.length(), getBlockSize());
byte[] data = new byte[length];
InputStream in = new FileInputStream(f);
try {
IOUtils.skipFully(in, id.pos);
IOUtils.readFully(in, data, 0, length);
} finally {
in.close();
}
return data;
}
代码示例来源:origin: apache/jackrabbit-oak
IOUtils.skipFully(idStream, len);
totalLength += len;
} else if (type == TYPE_HASH) {
IOUtils.skipFully(idStream, digestLength);
} else {
throw new IOException("Datastore id type " + type + " for blob " + blobId);
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
IOUtils.skipFully(idStream, len);
totalLength += len;
} else if (type == TYPE_HASH) {
IOUtils.skipFully(idStream, digestLength);
} else {
throw new IOException("Datastore id type " + type + " for blob " + blobId);
代码示例来源:origin: org.apache.jackrabbit/oak-blob
IOUtils.skipFully(idStream, len);
totalLength += len;
} else if (type == TYPE_HASH) {
IOUtils.skipFully(idStream, digestLength);
} else {
throw new IOException("Datastore id type " + type + " for blob " + blobId);
代码示例来源:origin: org.apache.jackrabbit/oak-blob
} else if (type == TYPE_DATA) {
int len = IOUtils.readVarInt(idStream);
IOUtils.skipFully(idStream, len);
} else if (type == TYPE_HASH) {
int level = IOUtils.readVarInt(idStream);
代码示例来源:origin: apache/jackrabbit-oak
} else if (type == TYPE_DATA) {
int len = IOUtils.readVarInt(idStream);
IOUtils.skipFully(idStream, len);
} else if (type == TYPE_HASH) {
int level = IOUtils.readVarInt(idStream);
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
} else if (type == TYPE_DATA) {
int len = IOUtils.readVarInt(idStream);
IOUtils.skipFully(idStream, len);
} else if (type == TYPE_HASH) {
int level = IOUtils.readVarInt(idStream);
代码示例来源:origin: apache/jackrabbit-oak
public void testSkipFully() throws IOException {
final Random r = new Random(1);
byte[] data = new byte[1000];
r.nextBytes(data);
FilterInputStream in = new FilterInputStream(new ByteArrayInputStream(data)) {
@Override
public int read(byte[] buffer, int off, int max) throws IOException {
return in.read(buffer, off, Math.min(10, max));
}
};
in.mark(10000);
IOUtils.skipFully(in, 1000);
assertEquals(-1, in.read());
in.reset();
try {
IOUtils.skipFully(in, 1001);
fail();
} catch (EOFException e) {
// expected
}
}
代码示例来源:origin: apache/jackrabbit-oak
int len = IOUtils.readVarInt(idStream);
if (pos < len) {
IOUtils.skipFully(idStream, (int) pos);
len -= pos;
if (length < len) {
return len;
IOUtils.skipFully(idStream, len);
pos -= len;
} else if (type == TYPE_HASH) {
byte[] block = readBlock(digest, readPos);
ByteArrayInputStream in = new ByteArrayInputStream(block);
IOUtils.skipFully(in, pos - readPos);
return IOUtils.readFully(in, buff, off, length);
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
int len = IOUtils.readVarInt(idStream);
if (pos < len) {
IOUtils.skipFully(idStream, (int) pos);
len -= pos;
if (length < len) {
return len;
IOUtils.skipFully(idStream, len);
pos -= len;
} else if (type == TYPE_HASH) {
byte[] block = readBlock(digest, readPos);
ByteArrayInputStream in = new ByteArrayInputStream(block);
IOUtils.skipFully(in, pos - readPos);
return IOUtils.readFully(in, buff, off, length);
代码示例来源:origin: org.apache.jackrabbit/oak-blob
int len = IOUtils.readVarInt(idStream);
if (pos < len) {
IOUtils.skipFully(idStream, (int) pos);
len -= pos;
if (length < len) {
return len;
IOUtils.skipFully(idStream, len);
pos -= len;
} else if (type == TYPE_HASH) {
byte[] block = readBlock(digest, readPos);
ByteArrayInputStream in = new ByteArrayInputStream(block);
IOUtils.skipFully(in, pos - readPos);
return IOUtils.readFully(in, buff, off, length);
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
} else if (type == TYPE_DATA) {
int len = IOUtils.readVarInt(idStream);
IOUtils.skipFully(idStream, len);
} else if (type == TYPE_HASH) {
int level = IOUtils.readVarInt(idStream);
代码示例来源:origin: apache/jackrabbit-oak
} else if (type == TYPE_DATA) {
int len = IOUtils.readVarInt(idStream);
IOUtils.skipFully(idStream, len);
} else if (type == TYPE_HASH) {
int level = IOUtils.readVarInt(idStream);
代码示例来源:origin: org.apache.jackrabbit/oak-blob
} else if (type == TYPE_DATA) {
int len = IOUtils.readVarInt(idStream);
IOUtils.skipFully(idStream, len);
} else if (type == TYPE_HASH) {
int level = IOUtils.readVarInt(idStream);
内容来源于网络,如有侵权,请联系作者删除!