提交 1feb1949 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use IOUtils.skipFully()

上级 5185d722
package org.h2.store;
import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.h2.util.IOUtils;
public final class RangeInputStream extends FilterInputStream {
private long limit;
public RangeInputStream(InputStream in, long offset, long limit) throws IOException {
super(in);
this.limit = limit;
while (offset > 0) {
long skip = in.skip(offset);
if (skip <= 0) {
int b = read();
if (b < 0)
throw new EOFException();
offset--;
} else {
offset -= skip;
}
}
IOUtils.skipFully(in, offset);
}
@Override
......
package org.h2.store;
import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;
import org.h2.util.IOUtils;
public final class RangeReader extends Reader {
private final Reader r;
......@@ -12,17 +13,7 @@ public final class RangeReader extends Reader {
public RangeReader(Reader r, long offset, long limit) throws IOException {
this.r = r;
this.limit = limit;
while (offset > 0) {
long skip = r.skip(offset);
if (skip <= 0) {
int ch = read();
if (ch < 0)
throw new EOFException();
offset--;
} else {
offset -= skip;
}
}
IOUtils.skipFully(r, offset);
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论