Skip to content

Commit e69e27f

Browse files
committed
BytesHandle: return -1 on EOF
1 parent 6c094f7 commit e69e27f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/org/scijava/io/handle/BytesHandle.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ public void setLength(final long length) throws IOException {
8787

8888
@Override
8989
public int read(final byte[] b, final int off, int len) throws IOException {
90+
if(len == 0) return 0;
9091
if (offset + len > length()) {
9192
len = (int) (length() - offset);
9293
}
94+
if(len == 0) { // EOF
95+
return -1;
96+
}
9397
bytes().getBytes(offset, b, off, len);
9498
offset += len;
9599
return len;

0 commit comments

Comments
 (0)