rdhaese
10/2/2017 - 6:43 AM

Create InputStream of size

Utility method that allows to create an InputStream of a certain size.

    private static final Integer BYTE_IN_MEGABYTE = 1000000;

    public static InputStream createInputStreamOfSize(final Integer sizeInMb) {
        byte[] file = new byte[BYTE_IN_MEGABYTE * sizeInMb];
        Arrays.fill(file, (byte) 1);
        return new ByteArrayInputStream(file);
    }