Java File Size Readable Format formatSize(long bytes, String b, String kb, String mb, String gb)

Here you can find the source of formatSize(long bytes, String b, String kb, String mb, String gb)

Description

format Size

License

Open Source License

Declaration

public static String formatSize(long bytes, String b, String kb, String mb, String gb) 

Method Source Code

//package com.java2s;

public class Main {
    private static final long K = 1024;
    private static final long M = 1024 * K;
    private static final long G = 1024 * M;

    public static String formatSize(long bytes, String b, String kb, String mb, String gb) {
        if (bytes > 16L * G)
            return (bytes / G) + gb;
        else if (bytes > 16L * M)
            return (bytes / M) + mb;
        else if (bytes > 16L * K)
            return (bytes / K) + kb;
        else/*from   www . ja v  a  2  s .  com*/
            return bytes + b;
    }
}

Related

  1. formatSeperatorRow(int[] sizes)
  2. formatShortByte(long size)
  3. formatSize(double size)
  4. formatSize(Integer size)
  5. formatSize(long bytes)
  6. formatSize(long size)
  7. formatSize(long size)
  8. formatSize(long size)
  9. formatSize(long size)