Java Byte Value Format bytesToHumanReadable(int bytes)

Here you can find the source of bytesToHumanReadable(int bytes)

Description

bytes To Human Readable

License

Open Source License

Declaration

public static String bytesToHumanReadable(int bytes) 

Method Source Code

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

public class Main {
    public static String bytesToHumanReadable(int bytes) {
        float fbytes = (float) bytes;
        String[] mags = new String[] { "", "k", "m", "g", "t" };
        int magIndex = 0;
        while (fbytes >= 1024) {
            fbytes /= 1024;//w  w w.  j a  v  a 2s .co  m
            magIndex++;
        }
        return String.format("%.2f%sb", fbytes, mags[magIndex]);
    }
}

Related

  1. bytesToGB(long bytes)
  2. bytesToHuman(long bytes)
  3. bytesToHuman(long size)
  4. bytesToKBytes(long bytes)
  5. bytesToMagaBytes(long bytes)
  6. BytesToMB(long kb)
  7. bytesToMB(long sizeInBytes)