RFR: 8285452: Add a new test library API to replace a file content using FileUtils.java [v7]

Daniel Fuchs dfuchs at openjdk.java.net
Fri Apr 29 14:22:43 UTC 2022


On Fri, 29 Apr 2022 13:02:06 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Also calling trim() assumes that white spaces are not significant. This might not be the case in the general case (for instance - think of markdown files were leading spaces are significant).
>
> The comparison is intentionally made lax so the caller does not need to provide the exact indentation or even new line characters. We think along with `fromLine` and `toLine` this is enough to make sure we are not modifying the wrong lines.

Shouldn't the comparison be better implemented by the caller then, who will know whether spaces are important or not? That's why I had suggested taking a `Predicate<String>` that could be called with each line removed, and the caller could interrupt the parsing by returning false when it detects a mismatch with what they expect.

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

PR: https://git.openjdk.java.net/jdk/pull/8360


More information about the core-libs-dev mailing list