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

Andy Goryachev duke at openjdk.org
Fri Jul 8 16:04:25 UTC 2022


On Fri, 8 Jul 2022 06:24:54 GMT, Abhishek Kumar <duke at openjdk.org> wrote:

>> Yet JDK isn't localised into Arabic. Some Slavic languages have different plural forms which depend on the last digit in the number (except for 10-19).
>> 
>> It is probably the reason why Windows Explorer shows the size in KB. On the other hand, Properties dialog shows the size as "0 bytes" and "1 bytes".
>
>> Shall we handle "1 byte"?
> 
> "1 byte" is not handled separately. In that case, should I replace "0 bytes" with "{0} B" ?

Please refer to MessageFormat javadoc:

`For more sophisticated patterns, you can use a ChoiceFormat to produce correct forms for singular and plural:

 MessageFormat form = new MessageFormat("The disk "{1}" contains {0}.");
 double[] filelimits = {0,1,2};
 String[] filepart = {"no files","one file","{0,number} files"};
 ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
 form.setFormatByArgumentIndex(0, fileform);

 int fileCount = 1273;
 String diskName = "MyDisk";
 Object[] testArgs = {new Long(fileCount), diskName};

 System.out.println(form.format(testArgs));
 
The output with different values for fileCount:
 The disk "MyDisk" contains no files.
 The disk "MyDisk" contains one file.
 The disk "MyDisk" contains 1,273 files.`

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

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



More information about the client-libs-dev mailing list