I want code that i can get file size and change it to KB and MB
562 KB = 562 KB
1024 KB = 1 MB
2152 KB = 2.15 MB
thank you in advance.
I want code that i can get file size and change it to KB and MB
562 KB = 562 KB
1024 KB = 1 MB
2152 KB = 2.15 MB
thank you in advance.
Here it's:
public String size(int size){
String hrSize = "";
double m = size/1024.0;
DecimalFormat dec = new DecimalFormat("0.00");
if (m > 1) {
hrSize = dec.format(m).concat(" MB");
} else {
hrSize = dec.format(size).concat(" KB");
}
return hrSize;
}