Java Number Format formatBytesHumanReadable(float number)

Here you can find the source of formatBytesHumanReadable(float number)

Description

format Bytes Human Readable

License

Open Source License

Declaration

public static String formatBytesHumanReadable(float number) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String formatBytesHumanReadable(float number) {
        String unit = "bytes";
        if (number > 1024) {
            number /= 1024;//w  ww. ja  v  a 2s  . co  m
            unit = "KiB";
        }
        if (number > 1024) {
            number /= 1024;
            unit = "MiB";
        }
        number = (float) ((long) (number * 1000)) / 1000;
        return number + " " + unit;
    }
}

Related

  1. format(String number)
  2. format(String number)
  3. formatAmountDigits(String numberString, int length)
  4. formatBinaryNumber(int number, int size)
  5. formatBytes(long number)
  6. formatCardNumber(String cardNumber)
  7. formatCCNumber(String f, String s)
  8. formatCsv(final Number number)
  9. formatFolioNumber(Integer folioNum, String folioMod)