Code example for DecimalFormat

Methods: format

0
	 */ 
	public static String GetFileSize(long size){
		int kbSize=(int)size/1024;
		if(kbSize>1024){
			float mbSize=kbSize/1024;
			DecimalFormat formator=new DecimalFormat( "##,###,###.## ");
			return formator.format(mbSize) + "M";
		} 
		return kbSize + "K";
	} 
} 
Connect your IDE to all the code out there  Get Codota for Java