@Nonnegative
    public static int writeZeros(@Nonnegative int numberOfZeros, @Nonnull DataOutput to) throws IOException {
        final byte[] buffer = DEFAULT_BUFFER_SIZE.allocate();
        int totalWritten = 0;
        while (totalWritten < numberOfZeros) {
            final int numberOfBytesWriteNow = ((totalWritten + buffer.length) <= numberOfZeros) ? buffer.length : (numberOfZeros - totalWritten);
            to.write(buffer, 0, numberOfBytesWriteNow);
            totalWritten += numberOfBytesWriteNow;
        }
        if (totalWritten != numberOfZeros) {
            throw new IllegalStateException("Write to much from stream? Write " + byteCountOf(totalWritten) + " but expected was " + byteCountOf(numberOfZeros) + ".");
        }
        return numberOfZeros;
    }
@ Nonnegative public static int writeZeros ( @ Nonnegative int numberOfZeros , @ Nonnull DataOutput to ) throws IOException { final byte [ ] buffer = DEFAULT_BUFFER_SIZE . allocate ( ) ; int totalWritten = 0 ; while ( totalWritten < numberOfZeros ) { final int numberOfBytesWriteNow = ( ( totalWritten + buffer . length ) <= numberOfZeros ) ? buffer . length : ( numberOfZeros - totalWritten ) ; to . write ( buffer , 0 , numberOfBytesWriteNow ) ; totalWritten += numberOfBytesWriteNow ; } if ( totalWritten != numberOfZeros ) { throw new IllegalStateException ( "Write to much from stream? Write " + byteCountOf ( totalWritten ) + " but expected was " + byteCountOf ( numberOfZeros ) + "." ) ; } return numberOfZeros ; }
@return number of written bytes.