RFR: 8285452: Support new API to replace a file content using FileUtils.java [v3]
Weijun Wang
weijun at openjdk.java.net
Wed Apr 27 14:12:46 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
I've updated the title of the bug. Siba can update the PR title.
You're right that it's not easy to discover such APIs. We put it in `FileUtils` hoping people who does not want to write their own method will search from there first.
As for the API itself, we've imagined something like
FileUtils.patch(inputFile)
.with(1, 10, List.of(lines), List.of(newLines))
.with(100, 100, linesAsAString, newLinesAsAString)
.writeTo(outputFile)
but the current form is the simplest case and could be kept even if we have a verbose one.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8360
More information about the core-libs-dev
mailing list