public static String formatSize ( final long value ) { double size = value ; DecimalFormat df = new DecimalFormat ( "#.##" ) ; if ( size >= GB ) { return df . format ( size / GB ) + " GB" ; } if ( size >= MB ) { return df . format ( size / MB ) + " MB" ; } if ( size >= KB ) { return df . format ( size / KB ) + " KB" ; } return String . valueOf ( ( int ) size ) + " bytes" ; }
Returns formatted size of a file size .