android长度转单位
public static String formatFileLength(long length) {
if (length >> 30 > 0L) {
float sizeGb = Math.round(10.0F * (float) length / 1.073742E+009F) / 10.0F;
return sizeGb + " GB";
}
if (length >> 20 > 0L) {
return formatSizeMb(length);
}
if (length >> 9 > 0L) {
float sizekb = Math.round(10.0F * (float) length / 1024.0F) / 10.0F;
return sizekb + " KB";
}
return length + " B";
}
public static String formatSizeMb(long length) {
float mbSize = Math.round(10.0F * (float) length / 1048576.0F) / 10.0F;
return mbSize + " MB";
}