aliocrlib/src/main/java/com/lib/aliocr/utils/io/FileUtil.java
/**
     * Returns a human-readable version of the file size, where the input
     * represents a specific number of bytes.
     *
     * @param size the number of bytes
     * @return a human-readable display value (includes units)
     */
Returns a human-readable version of the file size, where the input
represents a specific number of bytes.

@param size the number of bytes
@return a human-readable display value (includes units)
Returns a human - readable version of the file size where the input represents a specific number of bytes . @param size the number of bytes @return a human - readable display value ( includes units )
public static String formatSize(long size) {
        float ONE_KB = 1024F;
        float ONE_MB = ONE_KB * ONE_KB;
        float ONE_GB = ONE_KB * ONE_MB;
        String displaySize;
        DecimalFormat df = new DecimalFormat("0.0");
        if (size >= ONE_KB && size < ONE_MB) {
            displaySize = String.valueOf(df.format(size / ONE_KB)) + " KB";
        } else if (size >= ONE_MB && size < ONE_GB) {
            displaySize = String.valueOf(df.format(size / ONE_MB)) + " MB";
        } else if (size >= ONE_GB) {
            displaySize = String.valueOf(df.format(size / ONE_GB)) + " GB";
        } else if (size == 0) {
            displaySize = " 0KB";
        } else {
            displaySize = "1KB";
            Log.d("formatSize",
                    String.valueOf(df.format(size)) + " B");
        }
        /*
         * else {
         * displaySize = String.valueOf(df.format(size)) + " B";
         * }
         */
        return displaySize;
    }
public static String formatSize ( long size ) { float ONE_KB = 1024F ; float ONE_MB = ONE_KB * ONE_KB ; float ONE_GB = ONE_KB * ONE_MB ; String displaySize ; DecimalFormat df = new DecimalFormat ( "0.0" ) ; if ( size >= ONE_KB && size < ONE_MB ) { displaySize = String . valueOf ( df . format ( size / ONE_KB ) ) + " KB" ; } else if ( size >= ONE_MB && size < ONE_GB ) { displaySize = String . valueOf ( df . format ( size / ONE_MB ) ) + " MB" ; } else if ( size >= ONE_GB ) { displaySize = String . valueOf ( df . format ( size / ONE_GB ) ) + " GB" ; } else if ( size == 0 ) { displaySize = " 0KB" ; } else { displaySize = "1KB" ; Log . d ( "formatSize" , String . valueOf ( df . format ( size ) ) + " B" ) ; } /*
         * else {
         * displaySize = String.valueOf(df.format(size)) + " B";
         * }
         */ return displaySize ; }
Returns a human-readable version of the file size, where the input
 represents a specific number of bytes.
Returns a human - readable version of the file size where the input represents a specific number of bytes .