try (Stream<String> lines = Files.lines(targetFile)) {
List<String> replacedContent = lines.map(line ->
StringUtils.replaceEach(line,keys, values))
.parallel()
.collect(Collectors.toList());
Files.write(targetFile, replacedContent);
}
I'm trying to replace multiple text patterns in each line of the file. But I'm observing that "\r\n"(byte equivalent 10 and 13) is being replaced with just "\r"(just 10) and my comparison tests are failing.
I want to preserve the newlines as they are in the input file and don't want java to touch them. Could anyone suggest if there is a way to do this without having to use a separate default replacement for "\r\n".