Java Double Number Readable Format humanBytes(double value)

Here you can find the source of humanBytes(double value)

Description

human Bytes

License

Apache License

Declaration

public static String humanBytes(double value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String humanBytes(double value) {
        String suffix = " B";
        if (value > 1024) {
            value /= 1024;/*from  ww  w.ja v a2  s.co  m*/
            suffix = " KB";
        }
        if (value > 1024) {
            value /= 1024;
            suffix = " MB";
        }
        if (value > 1024) {
            value /= 1024;
            suffix = " GB";
        }
        if (value > 1024) {
            value /= 1024;
            suffix = " TB";
        }
        return String.valueOf(Math.round(value * 100.0) / 100.0) + suffix;
    }
}

Related

  1. humanBytes(double bytes)
  2. humanReadableNumber(double n)
  3. humanReadableUnits(double bytes, boolean internationalSystemOfUnits)
  4. humanSize(double size)
  5. toMB(double inB)