[ https://issues.apache.org/jira/browse/IO-294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238227#comment-13238227 ]
Aaron Digulla commented on IO-294: ---------------------------------- It would probably belong to a new class in the package {{org.apache.commons.lang3.text}} but I fear that nobody will ever find it there. {{byteCountToDisplaySize()}} is a method that is strongly related to I/O - I can't think that we'd use that to print the size of String labels in a UI, for example. So it should go into commons IO somewhere but maybe into {{IOUtils}} since it's not especially related to files. And if you support I18n, you must allow to specify a locale. Otherwise, this code can't be used in a multi-language web app, for example. > 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 > > > 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 is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira