Java Byte Array Print printByteSize(long bytes)

Here you can find the source of printByteSize(long bytes)

Description

print Byte Size

License

Open Source License

Declaration

public static String printByteSize(long bytes) 

Method Source Code

//package com.java2s;

public class Main {
    public static String printByteSize(long bytes) {
        if (bytes >= 1073741824) {
            return "" + (Math.round(bytes / 1073741824 * 100) / 100) + "G";
        } else if (bytes >= 1048576) {
            return "" + (Math.round(bytes / 1048576 * 100) / 100) + "M";
        } else if (bytes >= 1024) {
            return "" + (Math.round(bytes / 1024 * 100) / 100) + "K";
        } else {/*from ww w  .j a v  a2  s. co m*/
            return "" + bytes + "B";
        }
    }
}

Related

  1. printBytes(byte[] bytes, int offset)
  2. printBytes(byte[] data)
  3. printBytes(String comment, byte[] input)
  4. printBytes(String x)
  5. printBytesHexEncoded(final byte[] byteArray)
  6. printBytesToString(byte[] bytes, String structName)
  7. printByteWithChar(byte[] byteArray)