如何修复 RAM 格式大小?

How to fix RAM format size?

如果 RAM 大于 1 GB,则不会显示确切的 RAM。

如何重新格式化?

 public static String formatSize(long size) {
    String suffix = null;

    if (size >= 1024) {
        suffix = " KB ";
        size /= 1024;
        if (size >= 1024) {
            suffix = " MB ";
            size /= 1024;
        }
    }

试试这个

private static String formatSize(long size) {
        long Kb = 1024;
        long Mb = Kb * 1024;
        long Gb = Mb * 1024;
        long Tb = Gb * 1024;
        long Pb = Tb * 1024;
        long Eb = Pb * 1024;

        if (size < Kb) return floatForm(size) + " byte";
        if (size >= Kb && size < Mb) return floatForm((double) size / Kb) + " Kb";
        if (size >= Mb && size < Gb) return floatForm((double) size / Mb) + " Mb";
        if (size >= Gb && size < Tb) return floatForm((double) size / Gb) + " Gb";
        if (size >= Tb && size < Pb) return floatForm((double) size / Tb) + " Tb";
        if (size >= Pb && size < Eb) return floatForm((double) size / Pb) + " Pb";
        if (size >= Eb) return floatForm((double) size / Eb) + " Eb";

        return "???";
    }

 private static String floatForm(double d) {
        return new DecimalFormat("#.##").format(d);
    }