31 lines
659 B
Plaintext
31 lines
659 B
Plaintext
== Compliant Solution
|
|
|
|
[source,text]
|
|
----
|
|
private void readTheFile(String fileName) throws IOException {
|
|
Path path = Paths.get(fileName);
|
|
try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
|
|
reader.readLine();
|
|
// ...
|
|
}
|
|
// ..
|
|
try (Stream<String> input = Files.lines("input.txt")) {
|
|
input.forEach(System.out::println);
|
|
}
|
|
}
|
|
|
|
private void doSomething() {
|
|
OutputStream stream = null;
|
|
try {
|
|
stream = new FileOutputStream("myfile.txt");
|
|
for (String property : propertyList) {
|
|
// ...
|
|
}
|
|
} catch (Exception e) {
|
|
// ...
|
|
} finally {
|
|
stream.close();
|
|
}
|
|
}
|
|
----
|