Close file ready with try-with-resources
This commit is contained in:
parent
714aeca9b4
commit
2934bb11ea
1 changed files with 4 additions and 2 deletions
|
@ -32,6 +32,7 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the README file.
|
* Writes the README file.
|
||||||
|
@ -94,8 +95,9 @@ class ReadmeWriter implements CommandLineRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readFile(final Path file) throws IOException {
|
private String readFile(final Path file) throws IOException {
|
||||||
return Files.lines(file, StandardCharsets.UTF_8)
|
try (Stream<String> lines = Files.lines(file, StandardCharsets.UTF_8)) {
|
||||||
.collect(Collectors.joining(NEWLINE));
|
return lines.collect(Collectors.joining(NEWLINE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue