public String addUnits( String value ) {

		StringBuffer buff = new StringBuffer(100);
		
		long bytes = Long.parseLong(value);

		if( bytes < 1000000 ) {
			
			buff.append(value);
			buff.append("B");
			
		} else {
			
			int unit = 1000;
			int exp = (int) (Math.log(bytes) / Math.log(unit));
			String pre = "kMGTPE".charAt(exp-1)+"";
			String ov = String.format("%.1f%sB", bytes / Math.pow(unit, exp), pre);
			buff.append(ov);
			
		}

		return buff.toString();
		
	}
public String addUnits ( String value ) { StringBuffer buff = new StringBuffer ( 100 ) ; long bytes = Long . parseLong ( value ) ; if ( bytes < 1000000 ) { buff . append ( value ) ; buff . append ( "B" ) ; } else { int unit = 1000 ; int exp = ( int ) ( Math . log ( bytes ) / Math . log ( unit ) ) ; String pre = "kMGTPE" . charAt ( exp - 1 ) + "" ; String ov = String . format ( "%.1f%sB" , bytes / Math . pow ( unit , exp ) , pre ) ; buff . append ( ov ) ; } return buff . toString ( ) ; }
Utility method to include the SI unit name.
@param value The value of a Long in String form.
@return Rounded value with appended SI units.  For example, 45.3MB, 62B, 27.2GB, etc.