[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-tabpanelfocusedCommentId=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 * liSupports the SI or IEC units./li * liSupports I18n/li * liDisplay a one digit remainder (rounded down if less than 5, rounded up otherwise)/li * liOnce 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)
[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-tabpanelfocusedCommentId=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 * liSupports the SI or IEC units./li * liSupports I18n/li * liDisplay a one digit remainder (rounded down if less than 5, rounded up otherwise)/li * liOnce 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
[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-tabpanelfocusedCommentId=13168845#comment-13168845 ] Jean-Noel Rouvignac commented on IO-294: @Sebb: FileUtils already has this other byteCountToDisplaySize() method, so I thought it was the right place to add it. Do you have a class you can suggest for adding this in Commons Lang? Cheers. 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: * ul * liSupports the SI or IEC units./li * liSupports I18n/li * liDisplay a one digit remainder (rounded down if less than 5, rounded up otherwise)/li * liOnce 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
[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-tabpanelfocusedCommentId=13167709#comment-13167709 ] Sebb commented on IO-294: - Looks useful; however I'm not sure FileUtils is the correct place for it, as bytes are also used for network sizes, etc. The main part of the code purely deals with numbers, and is not specifically related to IO - perhaps it belongs in Lang? 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: * ul * liSupports the SI or IEC units./li * liSupports I18n/li * liDisplay a one digit remainder (rounded down if less than 5, rounded up otherwise)/li * liOnce 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
[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-tabpanelfocusedCommentId=13167711#comment-13167711 ] Jean-Noel Rouvignac commented on IO-294: Also, FileUtils.byteCountToDisplaySize(long size) could also be changed to use this new method if you are not too worried about the compatibility of its output compared to previous versions. 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: * ul * liSupports the SI or IEC units./li * liSupports I18n/li * liDisplay a one digit remainder (rounded down if less than 5, rounded up otherwise)/li * liOnce 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