Java Long Number Readable Format formatBytes(long bytes)

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

Description

format Bytes

License

Artistic License

Declaration

public static String formatBytes(long bytes) 

Method Source Code

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

public class Main {
    public static String formatBytes(long bytes) {
        if (bytes < 1024) {
            return bytes + "b";
        }/*  ww w .j a va 2 s.  c o  m*/

        bytes = bytes / 1024;

        if (bytes < 1024) {
            return bytes + "kb";
        }

        bytes = bytes / 1024;

        if (bytes < 1024) {
            return bytes + "mb";
        }

        bytes = bytes / 1024;

        return bytes + "GB";
    }
}

Related

  1. formatBytes(long bytes)
  2. formatBytes(long bytes)
  3. formatBytes(long bytes)
  4. formatBytes(long bytes)
  5. formatBytes(long bytes)
  6. formatBytes(long bytes)
  7. formatBytes(long bytes)
  8. formatBytes(long bytes)
  9. formatBytes(long d)