提交 f19f7723 编写于 作者: F Fred G

[FIXED JENKINS-16630] Human readable file size method returns ",00" for

files with byte length 0 
上级 c9adc144
...@@ -1548,6 +1548,9 @@ public class Functions { ...@@ -1548,6 +1548,9 @@ public class Functions {
*/ */
public static String humanReadableByteSize(long size){ public static String humanReadableByteSize(long size){
String measure = "B"; String measure = "B";
if(size < 1024){
return size + " " + measure;
}
Double number = new Double(size); Double number = new Double(size);
if(number>=1024){ if(number>=1024){
number = number/1024; number = number/1024;
...@@ -1561,7 +1564,7 @@ public class Functions { ...@@ -1561,7 +1564,7 @@ public class Functions {
} }
} }
} }
DecimalFormat format = new DecimalFormat("##.00"); DecimalFormat format = new DecimalFormat("#0.00");
return format.format(number) + " " + measure; return format.format(number) + " " + measure;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册