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

Benedikt Ritter commented on IO-373:
------------------------------------

How about adding something like 
[java.util.concurrent.TimeUnit|http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html]?
 It could look something like this:

{code:java}
FileSize.KILOBYTES.displaySize(1024);
{code}

This would translate 1024 bytes to kilobytes. We would also need a static 
method in {{FileSize}} that can figure out which unit best matches:

{code:java}
FileSize.optimalDisplaySize(1024);
{code}

It makes sense to have a method with a default precision and one where you can 
pass the desired as parameter.
The FileSize class could also help when translating between sizes:

{code:java}
FileSize.BYTES.toMegaBytes(1024 * 3L);
{code}

Another thing I've thought about is to distinguish between [metric 
prefixes|http://en.wikipedia.org/wiki/Metric_prefix] and [binary 
prefixes|http://en.wikipedia.org/wiki/Binary_prefix] but I'm not sure if there 
are use cases for translating file sizes with metric factors.

Thoughts?
                
> FileUtils.byteCountToDisplaySize improvement/rounding issues
> ------------------------------------------------------------
>
>                 Key: IO-373
>                 URL: https://issues.apache.org/jira/browse/IO-373
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 2.4
>            Reporter: Mark
>            Priority: Minor
>
> Issue IO-226 is not fixed but closed.
> ?
> Here is my solution that also support a user-defined precision in terms of a 
> maximum length of the digits part.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to