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

Abhishek Kumar duke at openjdk.org
Fri Aug 12 19:56:53 UTC 2022


On Wed, 10 Aug 2022 18:39:58 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>>> > > If we display the file size with one decimal point precision, then it doesn't hold at all until the file size reaches 1 KB.
>>> 
>>> Is your point ( pun intended) that it looks like we are displaying files to a decimal precision, but in fact are not ?
>>> 
>>> ie it is very odd to display 1.0kb for files of 100, 200, 300, etc bytes .. What is the reason for displaying them all as 1.0kb .. this review is so long I'm not sure I am following any more.
>>> 
>>> Could we get a summary in a few sentences of the entire current proposal and the justification for it ?
>> 
>> There was an issue with plural forms if we show file sizes in terms of bytes. So, it has been discussed that 
>> we can show the file size in terms of "1 KB" for files having size >0 and <1000 bytes. To keep file size similar to native file system, JFileChooser displays file sizes with one decimal point precision.
>> 
>> Now, the issue is whether an empty file should be displayed as "0.0 KB" or "0 KB" ? 
>> As of now empty files are displayed as "0 KB".
>
>> > > > If we display the file size with one decimal point precision, then it doesn't hold at all until the file size reaches 1 KB.
>> > 
>> > Is your point ( pun intended) that it looks like we are displaying files to a decimal precision, but in fact are not ?
> 
> That's exactly my point.
> 
> 
>> > Could we get a summary in a few sentences of the entire current proposal and the justification for it ?
> 
> I also asked for the summary. That time it was a bit different:
> https://github.com/openjdk/jdk/pull/9327#discussion_r939828467
> 
>> There was an issue with plural forms if we show file sizes in terms of bytes. So, it has been discussed that we can show the file size in terms of "1 KB" for files having size >0 and <1000 bytes. To keep file size similar to native file system, JFileChooser displays file sizes with one decimal point precision.
>> 
>> Now, the issue is whether an empty file should be displayed as "0.0 KB" or "0 KB" ? As of now empty files are displayed as "0 KB".
> 
> The original issue is that we displayed a zero-sized file as 1 KB. It's stated in the bug subject and in the bug description with more details.
> 
> The initial fix was to display it as 0 bytes, which leads to localisation problems, especially if we take into account 1 byte.
> 
> Eventually, it was decided to display the size in KB. Thus zero-sized file is displayed as 0 KB, and one-byte-sized file is displayed as 1 KB. This is fine.
> 
> Later on, the decimal point was added to mimic native file navigation app in Ubuntu. Now for files larger than 1 KB, the size is shown up to one decimal point. Yet all the files below 1 KB are still displayed as 1 KB. I think it is confusing. If we care to display the size with one decimal point for larger files, why can't we display the size of smaller files with the same precision?
> 
> So, 0 bytes is 0.0 KB; > 0 and <= 100 bytes is 0.1 KB, and so on.
> 
> Alternatively, drop the decimal altogether.

@aivanov-jdk  I have implemented the suggested changes.

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

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



More information about the client-libs-dev mailing list