Here you can find the source of formatBytes(long bts)
public static String formatBytes(long bts)
//package com.java2s; //License from project: Apache License public class Main { public static String formatBytes(long bts) { long bt = bts % 1024; long kb = (bts / 1024) % 1024; long mb = bts / (1024 * 1024); return ((mb > 0) ? (mb + "MB,") : "") + ((kb > 0) ? (kb + "KB,") : "") + ((bt > 0) ? (bt + "BYTES") : ""); }/*from w w w .j a v a 2s . co m*/ }