List of usage examples for org.apache.commons.io FileUtils ONE_GB
long ONE_GB
To view the source code for org.apache.commons.io FileUtils ONE_GB.
Click Source Link
From source file:org.kuali.student.git.importer.ReportBlobSizePerBranch.java
private static BigDecimal getGB(BigDecimal counter) { return counter.divide(new BigDecimal(FileUtils.ONE_GB)); }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Converts the passed value into a string in Mb and returns a string * version of it.//from w w w. ja v a2s .c om * * @param v The value to convert. * @return See above. */ public static String formatFileSize(long v) { if (v <= 0) return ""; String s = ""; if (v < FileUtils.ONE_KB) s = String.format("%.1f", (double) v) + " bytes"; else if (v >= FileUtils.ONE_KB && v < FileUtils.ONE_MB) s = String.format("%.1f", ((double) v / FileUtils.ONE_KB)) + " Kb"; else if (v >= FileUtils.ONE_MB && v < FileUtils.ONE_GB) s = String.format("%.1f", ((double) v / FileUtils.ONE_MB)) + " Mb"; else if (v >= FileUtils.ONE_GB) s = String.format("%.1f", ((double) v / FileUtils.ONE_GB)) + " Gb"; return s; }
From source file:org.openvpms.web.component.mail.MailEditor.java
/** * Helper to format a size./*from w w w . j ava 2 s . co m*/ * * @param size the size, in bytes * @return the formatted size */ private String getSize(long size) { String result; if (size / FileUtils.ONE_GB > 0) { result = getSize(size, FileUtils.ONE_GB, "mail.size.GB"); } else if (size / FileUtils.ONE_MB > 0) { result = getSize(size, FileUtils.ONE_MB, "mail.size.MB"); } else if (size / FileUtils.ONE_KB > 0) { result = getSize(size, FileUtils.ONE_KB, "mail.size.KB"); } else { result = Messages.format("mail.size.bytes", size); } return result; }