List of utility methods to do File Size Readable Format
String | FormatFileSize(String filesize) Make file size format int len = 0; int mok = 0; int mod = 0; String result = ""; String reverseResult = ""; String stringMok = ""; String reverseMok = ""; len = filesize.length(); ... |
String | formatFilesize(String filesize, int decimalPlaces) Formats a file size string if it is a numeric representation stored in bytes. try { int multipleCount = 0; long filesizeValue = Long.parseLong(filesize); long filesizeRemainder = 0; while (filesizeValue > 1024 && multipleCount < filesizeSuffixes.length) { filesizeRemainder = filesizeValue % 1024; filesizeValue /= 1024; multipleCount++; ... |
String | formatFileStats(final String label, final long fileCount, final Object rawSize) Formats an object's file statistics for display. long size = 0; if (rawSize != null) { if (rawSize instanceof Integer) { size = (Integer) rawSize; } else if (rawSize instanceof Long) { size = (Long) rawSize; if (label == null || label.equals("") || label.equalsIgnoreCase("total")) { return String.format("%s in %s files", formatSize(size), fileCount); return String.format("%s: %s in %s files", label, formatSize(size), fileCount); |
String | formatGroup(String str, int groupSize, int lineBreak) format Group StringBuffer buffer = new StringBuffer(); int line = 1; buffer.append("/* 1 */ \""); for (int i = 0; i < str.length(); i += groupSize) { buffer.append(str.substring(i, i + Math.min(str.length() - i, groupSize))); if ((i + groupSize) % lineBreak == 0) { buffer.append("\" +\n/* "); line++; ... |
String | formatIndex(int index, int totalSize) Format a number as String that can be always be large enough to hold "totalSize" digits. int digits = (int) (Math.ceil(Math.log(totalSize) / Math.log(10)) + .5); String s = "" + index; while (s.length() < digits) { s = "0" + s; return s; |
String | formatInt(int val, int size) format Int String formatter = "%0" + size + "d"; return String.format(formatter, val); |
String | formatRow(String[] values, int[] sizes) Format row. return formatRow(" ", values, sizes); |
String | formatSeperatorRow(int[] sizes) Format seperator row. String[] values = new String[sizes.length]; for (int i = 0; i < values.length; i++) { values[i] = DASHES; return formatRow(" ", values, sizes); |
String | formatShortByte(long size) format Short Byte return size + bytePostfix;
|
String | formatSize(double size) format Size int i; for (i = 0; size >= 1024 && i < 4; i++) { size /= 1024; return (Math.round(size * 100.0) / 100.0) + " " + SIZE_UNITS[i]; |