Java Long Number Readable Format formatBytes(long bytes)

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

Description

format Bytes

License

Apache License

Declaration

public static String formatBytes(long bytes) 

Method Source Code

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

public class Main {
    public static String formatBytes(long bytes) {
        String size = "";
        if (bytes > 1024 * 1024)
            size += (bytes / 1024 / 1024) + " MB (" + bytes + " Bytes)";
        else if (bytes > 1024)
            size += (bytes / 1024) + " KB (" + bytes + " Bytes)";
        else if (bytes > 1)
            size += bytes + " Bytes";
        else//from   w  w  w .j a va 2 s. co m
            size += bytes + " Byte";
        return size;
    }
}

Related

  1. convertHumanSize(long byteSize)
  2. convertLongToMega(long value)
  3. convertMbIntoGb(long megaBytes)
  4. formatBytes(long bts)
  5. formatBytes(long bytes)
  6. formatBytes(long bytes)
  7. formatBytes(long bytes)
  8. formatBytes(long bytes)
  9. formatBytes(long bytes)