public static String humanReadableByteCount(final long bytes) {
        final String[] units = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
        final int base = 1024;

        // When using the smallest unit no decimal point is needed, because it's the exact number.
        if (bytes < base) {
            return bytes + " " + units[0];
        }

        final int exponent = (int) (Math.log(bytes) / Math.log(base));
        final String unit = units[exponent];
        return StringUtils.f("%.1f %s", bytes / Math.pow(base, exponent), unit);
    }
@Test
    public void testHumanReadable() {
        assertThat(StringUtils.humanReadableByteCount(1024L * 1024L * 1024L * 5L + 1024L * 1024L * 512L)).isEqualTo("5.5 GiB");
        assertThat(StringUtils.humanReadableByteCount(1024L * 1024L * 1024L * 5L)).isEqualTo("5.0 GiB");
        assertThat(StringUtils.humanReadableByteCount(1024L * 1024L * 4L + 1024L * 900L)).isEqualTo("4.9 MiB");
        assertThat(StringUtils.humanReadableByteCount(1023)).isEqualTo("1023 B");
        assertThat(StringUtils.humanReadableByteCount(1024)).isEqualTo("1.0 KiB");
        assertThat(StringUtils.humanReadableByteCount(1024L * 1024L * 1024L * 1024L * 5L + 1024L * 1024L * 512L)).isEqualTo("5.0 TiB");
        assertThat(StringUtils.humanReadableByteCount(1024L * 5L + 512L)).isEqualTo("5.5 KiB");
    }