(double size)
| 39 | } |
| 40 | |
| 41 | public static String getSize(double size) { |
| 42 | if (size <= 0) return ""; |
| 43 | String[] units = new String[]{"bytes", "KB", "MB", "GB", "TB"}; |
| 44 | int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); |
| 45 | return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; |
| 46 | } |
| 47 | |
| 48 | public static String removeExt(String text) { |
| 49 | return text.contains(".") ? text.substring(0, text.lastIndexOf(".")) : text; |