RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB [v7]

Andy Goryachev angorya at openjdk.org
Wed Jul 20 15:18:35 UTC 2022


On Wed, 20 Jul 2022 08:17:09 GMT, Abhishek Kumar <duke at openjdk.org> wrote:

>> JFileChooser - empty file size issue fixed. 
>> For empty file, now the size 0 bytes.
>> Manual Test Case "ZeroFileSizeCheck.java" created.
>
> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   File Size shows upto 1 decimal value

src/java.desktop/share/classes/sun/swing/FilePane.java line 1192:

> 1190:                 setIcon(icon);
> 1191: 
> 1192:             } else if (value instanceof Long len) {

I think this code needs to be extracted into a function, and a unit test added.  Testing with different sizes and supported locales - let's say en_IN (Asian group separator) and ja_JP or zh_CN (no plural forms).

src/java.desktop/share/classes/sun/swing/FilePane.java line 1233:

> 1231: 
> 1232:     public double formatToDoubleValue(long len) {
> 1233:         DecimalFormat df = new DecimalFormat("0.0");

two comments:
1. you can safely return a formatted string instead of another double
2. should there be a group separator?  i.e. should you get a locale-specific NumberFormat instance?

-------------

PR: https://git.openjdk.org/jdk/pull/9327



More information about the client-libs-dev mailing list