RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB [v14]
Abhishek Kumar
duke at openjdk.org
Mon Aug 8 05:21:25 UTC 2022
On Fri, 5 Aug 2022 14:56:30 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
>>
>> creating and deleting test files dynamically
>
> src/java.desktop/share/classes/sun/swing/FilePane.java line 1235:
>
>> 1233: DecimalFormat df = new DecimalFormat("0.0");
>> 1234: double val = len/baseFileSize;
>> 1235: return Double.valueOf(df.format(val));
>
> Can we achieve the same effect without converting the value from double to string and back to double?
>
> The returned value is `(len / 100L) / 10.0d`.
Yeah, it can be done like this.
> test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 62:
>
>> 60: Path dir = Paths.get(System.getProperty("test.src"));
>> 61: String [] tempFilesName = {"2.5-KB-File","2.8-MB-File","999-KB-File","1000-KB-File","2047-Byte-File","Empty-File"};
>> 62: int [] tempFilesSize = {2500, 2800000,999000,1000000,2047,0};
>
> Does it make sense to sort the files by size by prefixing them? "1-Empty-File", "2-File-2047-Byte"?
>
> Add a space after the commas.
Updated the file size string array as suggested.
> test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 66:
>
>> 64: for (int i = 0 ; i < tempFilesName.length ; i++) {
>> 65: tempFilePaths[i] = dir.resolve(tempFilesName[i]);
>> 66: }
>
> Can't the body of this for-loop be part of the next one?
>
> There should be no space before the semi-colon.
Ok, I will make changes.
-------------
PR: https://git.openjdk.org/jdk/pull/9327
More information about the client-libs-dev
mailing list