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

Abhishek Kumar duke at openjdk.org
Wed Jul 13 06:28:19 UTC 2022


On Fri, 8 Jul 2022 16:01:13 GMT, Andy Goryachev <duke at openjdk.org> wrote:

>>> 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.`

bytes replace by "B" to handle plural forms as suggested.

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

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



More information about the client-libs-dev mailing list