RFR/RFC (M) 7902575: Various code cleanups

Henri Tremblay henri.tremblay at gmail.com
Tue Jan 21 14:19:23 UTC 2020


Ok. Found it actually. In FileUtils. There are unbuffered readings. But
actually, not that I read the actual code instead of the diff, I can see it
is buffered. FileUtils could use `Files` a bit more but it's hard because
it's taking `Reader` in parameter and `Files` takes `Path` (which is
sad...). An example is this:

public static Collection<String> readAllLines(File file) throws IOException {
    try (FileReader fr = new FileReader(file)) {
        return readAllLines(fr);
    }
}

If could be

public static Collection<String> readAllLines(File file) throws IOException
{
    return Files.readAllLines(file.toPath());
}

and

public static void writeLines(File file, Collection<String> lines)
throws IOException {
    try (PrintWriter pw = new PrintWriter(file)) {
        for (String line : lines) {
            pw.println(line);
        }
        pw.close();
    }
}

could be, I think

public static void writeLines(File file, Collection<String> lines)
throws IOException {
    Files.write(file.toPath(), lines);
}


On Tue, 21 Jan 2020 at 02:11, Aleksey Shipilev <shade at redhat.com> wrote:

> On 1/21/20 3:17 AM, Henri Tremblay wrote:
> > Too late but all good to me (you changed to BufferedReader so I guess
> that came off-list).
>
> What exactly was your concern? Maybe it still holds true.
>
> > You could add some underscores to 1000000 in WinPerfAsmProfiler.
> Right. Let me do another sweep about those.
>
> --
> Thanks,
> -Aleksey
>
>


More information about the jmh-dev mailing list