|
@@ -29,9 +29,9 @@ import java.io.InputStreamReader;
|
29
|
29
|
import java.nio.charset.Charset;
|
30
|
30
|
import java.nio.file.Files;
|
31
|
31
|
import java.nio.file.Path;
|
32
|
|
-import java.util.ArrayList;
|
33
|
32
|
import java.util.Collections;
|
34
|
33
|
import java.util.List;
|
|
34
|
+import java.util.stream.Collectors;
|
35
|
35
|
|
36
|
36
|
/**
|
37
|
37
|
* Allows reading and writing to a plain text file via a list of lines.
|
|
@@ -157,11 +157,7 @@ public class TextFile {
|
157
|
157
|
public void readLines() throws IOException {
|
158
|
158
|
if (path == null) {
|
159
|
159
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, charset))) {
|
160
|
|
- lines = new ArrayList<>();
|
161
|
|
- String line;
|
162
|
|
- while ((line = reader.readLine()) != null) {
|
163
|
|
- lines.add(line);
|
164
|
|
- }
|
|
160
|
+ lines = reader.lines().collect(Collectors.toList());
|
165
|
161
|
}
|
166
|
162
|
} else {
|
167
|
163
|
lines = Files.readAllLines(path, charset);
|