I have different file sizes and need to create a user friendly output.
The size is a double like 0.5MB, 2.1MB.
Sometimes I get 2.0MB because I use the:
Double line = (double) size/(double)(1024*1024);
DecimalFormat dec = new DecimalFormat("0.0");
String result = dec.format(line);
I want to remove the zero from the the above if result==2.0
Think I need to create a new Double or maybe do string arrhythmic
Any suggestions?
Try
new DecimalFormat("0.#").