public int [ ] readInts ( int length ) throws KryoException { int [ ] array = new int [ length ] ; if ( optional ( length << 2 ) == length << 2 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 4 ) { array [ i ] = buffer [ p ] & 0xFF // | ( buffer [ p + 1 ] & 0xFF ) << 8 // | ( buffer [ p + 2 ] & 0xFF ) << 16 // | ( buffer [ p + 3 ] & 0xFF ) << 24 ; } position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readInt ( ) ; } return array ; }
Reads an int array in bulk . This may be more efficient than reading them individually .