Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.1
-
None
-
None
Description
I have written a little Utility method that might benefit Commons IO:
public class FileUtils { /** * Returns a human-readable version of the file size (original is in bytes). The implementation has the following features: * <ul> * <li>Supports the SI or IEC units.</li> * <li>Supports I18n</li> * <li>Display a one digit remainder (rounded down if less than 5, rounded up otherwise)</li> * <li>Once the main unit is >= 100, drops the remainder which would be over precision.</li> * </ul> * * @param size The number of bytes. * @param useSiUnits if false, uses the IEC (International Electrotechnical Commission) units (powers of 2), else uses SI (International System of Units) * units (powers of 10). * @return A human-readable display value (includes units). */ public static String byteCountToDisplaySize(long size, boolean useSiUnits) {
Attachments
Attachments
Issue Links
- is duplicated by
-
IO-373 FileUtils.byteCountToDisplaySize improvement/rounding issues
- Open