private String toLengthText ( long bytes ) { if ( bytes < 1024 ) { return bytes + " B" ; } else if ( bytes < 1024 * 1024 ) { return ( bytes / 1024 ) + " KB" ; } else if ( bytes < 1024 * 1024 * 1024 ) { return String . format ( "%.2f MB" , bytes / ( 1024.0 * 1024.0 ) ) ; } else { return String . format ( "%.2f GB" , bytes / ( 1024.0 * 1024.0 * 1024.0 ) ) ; } }
Converts a number of bytes to a human - readable string