Attachment download

This commit is contained in:
M66B
2018-08-03 19:12:19 +00:00
parent bc9a26c2c7
commit 70e0913331
50 changed files with 205 additions and 112 deletions

View File

@@ -67,6 +67,14 @@ public class Helper {
return sb.toString();
}
static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
static StringBuilder getDebugInfo() {
StringBuilder sb = new StringBuilder();