File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/java/org/scijava/io/handle Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 3333
3434import java .io .Closeable ;
3535import java .io .DataInput ;
36+ import java .io .DataInputStream ;
3637import java .io .DataOutput ;
3738import java .io .EOFException ;
3839import java .io .IOException ;
@@ -445,6 +446,20 @@ default void readFully(final byte[] b) throws IOException {
445446 readFully (b , 0 , b .length );
446447 }
447448
449+ @ Override
450+ default void readFully (final byte [] b , final int off , final int len )
451+ throws IOException
452+ {
453+ // NB: Adapted from java.io.DataInputStream.readFully(byte[], int, int).
454+ if (len < 0 ) throw new IndexOutOfBoundsException ();
455+ int n = 0 ;
456+ while (n < len ) {
457+ int count = read (b , off + n , len - n );
458+ if (count < 0 ) throw new EOFException ();
459+ n += count ;
460+ }
461+ }
462+
448463 @ Override
449464 default int skipBytes (final int n ) throws IOException {
450465 // NB: Cast here is safe since the value of n bounds the result to an int.
You can’t perform that action at this time.
0 commit comments