Skip to content

Commit 6737660

Browse files
committed
use com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream instead of own implementation
1 parent 5196562 commit 6737660

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

src/main/java/dev/zarr/zarrjava/store/BufferedZipStore.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import javax.annotation.Nullable;
55
import java.io.ByteArrayOutputStream;
66
import java.io.IOException;
7-
import java.io.InputStream;
87
import java.nio.ByteBuffer;
98
import java.nio.file.Path;
109
import java.nio.file.Paths;
1110
import java.util.stream.Stream;
1211

13-
import org.apache.commons.compress.archivers.ArchiveEntry;
12+
import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream;
1413
import org.apache.commons.compress.archivers.zip.*;
1514

1615
import java.util.zip.CRC32;
@@ -270,29 +269,4 @@ public StoreHandle resolve(String... keys) {
270269
public String toString() {
271270
return "BufferedZipStore(" + underlyingStore.toString() + ")";
272271
}
273-
274-
static class ByteBufferBackedInputStream extends InputStream {
275-
private final ByteBuffer buf;
276-
277-
public ByteBufferBackedInputStream(ByteBuffer buf) {
278-
this.buf = buf;
279-
}
280-
281-
@Override
282-
public int read() {
283-
return buf.hasRemaining() ? (buf.get() & 0xFF) : -1;
284-
}
285-
286-
@Override
287-
public int read(byte[] bytes, int off, int len) {
288-
if (!buf.hasRemaining()) {
289-
return -1;
290-
}
291-
292-
int toRead = Math.min(len, buf.remaining());
293-
buf.get(bytes, off, toRead);
294-
return toRead;
295-
}
296-
}
297-
298272
}

0 commit comments

Comments
 (0)