You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Paul Benedict (JIRA)" <ji...@apache.org> on 2015/04/07 19:56:12 UTC

[jira] [Commented] (IO-294) Adding FileUtils.byteCountToDisplaySize(long size, boolean useSiUnits)

    [ https://issues.apache.org/jira/browse/IO-294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14483620#comment-14483620 ] 

Paul Benedict commented on IO-294:
----------------------------------

Some thoughts:
* I would prefer an Enum over a boolean parameter. 
* Regarding what package to put this in, I think FileUtils is still fine (it's remains here even in 2.4) and an enhancement to use SI units seems like the logical thing to do.
* Regarding the patch, the list of String[] abbreviations should be static -- no need to construct them on each method invocation.
* According to Wikipedia, the trend to use SI units is increasing (http://en.wikipedia.org/wiki/Timeline_of_binary_prefixes).



> Adding FileUtils.byteCountToDisplaySize(long size, boolean useSiUnits)
> ----------------------------------------------------------------------
>
>                 Key: IO-294
>                 URL: https://issues.apache.org/jira/browse/IO-294
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>    Affects Versions: 2.1
>            Reporter: Jean-Noel Rouvignac
>         Attachments: FileUtils.java, FileUtilsTest.java, IO-294_FileSizeUnit.patch
>
>
> I have written a little Utility method that might benefit Commons IO:
> {code}
> 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) {
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)