@Override
    public void transform(InputStream is, OutputStream os) throws IOException {
        byte[] input = IOUtils.toByteArray(is);
        int numSwaps = (int) Math.floor(swapProbability * input.length);
        //at least one swap
        numSwaps = numSwaps == 0 ? 1 : numSwaps;
        byte[] ret = new byte[input.length];
        System.arraycopy(input, 0, ret, 0, input.length);
        for (int i = 0; i < numSwaps; i++) {
            ret = swap(ret);
        }
        os.write(ret);
    }
randomly swaps spans from the input
tika-fuzzing/src/main/java/org/apache/tika/fuzzing/general/SpanSwapper.java