Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2C9409246 for ; Mon, 12 Dec 2011 19:06:03 +0000 (UTC) Received: (qmail 97811 invoked by uid 500); 12 Dec 2011 19:06:02 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 97722 invoked by uid 500); 12 Dec 2011 19:06:02 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 97622 invoked by uid 99); 12 Dec 2011 19:06:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Dec 2011 19:06:02 +0000 X-ASF-Spam-Status: No, hits=-2001.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Dec 2011 19:05:53 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 59E1010E032 for ; Mon, 12 Dec 2011 19:05:31 +0000 (UTC) Date: Mon, 12 Dec 2011 19:05:31 +0000 (UTC) From: "Jean-Noel Rouvignac (Updated) (JIRA)" To: issues@commons.apache.org Message-ID: <1796523395.2169.1323716731369.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <87132132.2167.1323716731213.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (IO-294) Adding FileUtils.byteCountToDisplaySize(long size, boolean useSiUnits) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/IO-294?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jean-Noel Rouvignac updated IO-294: ----------------------------------- Attachment: FileUtilsTest.java FileUtils.java > 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 > Fix For: 2.2 > > 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: > *
    > *
  • Supports the SI or IEC units.
  • > *
  • Supports I18n
  • > *
  • Display a one digit remainder (rounded down if less than 5, rounded up otherwise)
  • > *
  • Once the main unit is >= 100, drops the remainder which would be over precision.
  • > *
> * > * @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