RFR: 8285452: Support new API to replace a file content using FileUtils.java [v3]
Daniel Fuchs
dfuchs at openjdk.java.net
Fri Apr 22 16:16:41 UTC 2022
On Fri, 22 Apr 2022 14:35:14 GMT, Sibabrata Sahoo <ssahoo at openjdk.org> wrote:
>> A new API to support replacing selective lines with desired content.
>
> Sibabrata Sahoo has updated the pull request incrementally with one additional commit since the last revision:
>
> Update FileUtils.java
test/lib/jdk/test/lib/util/FileUtils.java line 402:
> 400: if (!removed.equals(froms)) {
> 401: throw new IOException("Removed not the same");
> 402: }
That's a bit strange. I would suggest to return the removed lines instead, or to pass a `Consumer<String>` (or even better, a `Predicate<String>` ?) that will accept the removed lines. You could continue to remove if the predicate returns true and throw if it returns false. It would also enable you to tell exactly which line failed the check.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8360
More information about the core-libs-dev
mailing list