@ Override public int read ( final byte [ ] buffer , final int bufPos , final int length ) throws IOException { int i = super . read ( buffer , bufPos , length ) ; if ( ( i == length ) || ( i == - 1 ) ) return i ; int j = super . read ( buffer , bufPos + i , length - i ) ; if ( j == - 1 ) return i ; return j + i ; }
Workaround for an unexpected behavior of BufferedInputStream !