File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ public static String capitalize(String fieldName){
9494 //**************************************************************************
9595 //** rtrim
9696 //**************************************************************************
97+ /** Used to remove whitespaces at the end of a given string
98+ */
9799 public static String rtrim (String s ) {
98100 int i = s .length ()-1 ;
99101 while (i >= 0 && Character .isWhitespace (s .charAt (i ))) {
@@ -119,6 +121,25 @@ public static String getElapsedTime(long startTime){
119121 }
120122
121123
124+ //**************************************************************************
125+ //** formatFileSize
126+ //**************************************************************************
127+ public static String formatFileSize (long size ){
128+ if (size >0 ){
129+ size = size /1024 ;
130+ if (size <=1 ) return "1 KB" ;
131+ else {
132+ size = size /1024 ;
133+ if (size <=1 ) return "1 MB" ;
134+ else {
135+ return format (Math .round (size )) + " MB" ;
136+ }
137+ }
138+ }
139+ return "" ;
140+ };
141+
142+
122143 //**************************************************************************
123144 //** format
124145 //**************************************************************************
You can’t perform that action at this time.
0 commit comments