public static String bytesToHuman(long sizeInBytes) {

		NumberFormat nf = new DecimalFormat();
		nf.setMaximumFractionDigits(2);

		//init the human text
		String humanText = sizeInBytes + " Byte(s)";

		if (sizeInBytes < SPACE_KB) {
			humanText = nf.format(sizeInBytes) + " Byte(s)";
		} else if (sizeInBytes < SPACE_MB) {
			humanText = nf.format(sizeInBytes / SPACE_KB) + " KB";
		} else if (sizeInBytes < SPACE_GB) {
			humanText = nf.format(sizeInBytes / SPACE_MB) + " MB";
		} else if (sizeInBytes < SPACE_TB) {
			humanText = nf.format(sizeInBytes / SPACE_GB) + " GB";
		} else {
			humanText = nf.format(sizeInBytes / SPACE_TB) + " TB";
		}
		
		return humanText;
	}
public static String bytesToHuman ( long sizeInBytes ) { NumberFormat nf = new DecimalFormat ( ) ; nf . setMaximumFractionDigits ( 2 ) ; String humanText = sizeInBytes + " Byte(s)" ; if ( sizeInBytes < SPACE_KB ) { humanText = nf . format ( sizeInBytes ) + " Byte(s)" ; } else if ( sizeInBytes < SPACE_MB ) { humanText = nf . format ( sizeInBytes / SPACE_KB ) + " KB" ; } else if ( sizeInBytes < SPACE_GB ) { humanText = nf . format ( sizeInBytes / SPACE_MB ) + " MB" ; } else if ( sizeInBytes < SPACE_TB ) { humanText = nf . format ( sizeInBytes / SPACE_GB ) + " GB" ; } else { humanText = nf . format ( sizeInBytes / SPACE_TB ) + " TB" ; } return humanText ; }
Converts size in bytes to human representation with Byte(s), KB, MB, GB o
TB.

@param sizeInBytes
the size in bytes
@return text with Byte(s), KB, MB, GB o TB.