日期:2014-05-19 浏览次数:20947 次
int len = input.read(buffer, 0, buffer.length);
double tmp = (Math.round(((double)len / 1024.00)*100))/100.00;
public static String bytes2kb(long size) {
DecimalFormat df = new DecimalFormat("###.##");
float f;
if (size < 1024 * 1024) {
f = (float) ((float) size / (float) 1024);
return (df.format(new Float(f).doubleValue()) + "KB");
} else {
f = (float) ((float) size / (float) (1024 * 1024));
return (df.format(new Float(f).doubleValue()) + "MB");
}
}
public static void main(String[] args) {
System.out.println(bytes2kb(14022));
}
------解决方案--------------------
int i = 14022 ;
i = i*10/1024;
double d = i/10d ;
System.out.println(d);