回答編集履歴

1

せっかくなのでStream APIに一本化

2018/02/11 14:51

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -11,12 +11,6 @@
11
11
  import java.io.InputStreamReader;
12
12
 
13
13
  import java.io.IOException;
14
-
15
-
16
-
17
- import java.util.List;
18
-
19
- import java.util.stream.Collectors;
20
14
 
21
15
 
22
16
 
@@ -62,21 +56,29 @@
62
56
 
63
57
 
64
58
 
65
- List<String> lines = fIn.lines()
59
+ fIn.lines()
66
60
 
67
61
  .filter(line -> !line.startsWith(delId))
68
62
 
63
+ .forEach(line -> {
64
+
65
+ try {
66
+
67
+ fOut.write(line);
68
+
69
+ fOut.newLine();
70
+
71
+ }
72
+
73
+ catch(IOException e) {
74
+
69
- .collect(Collectors.toList())
75
+ throw new UncheckedIOException(e);
76
+
77
+ }
78
+
79
+ })
70
80
 
71
81
  ;
72
-
73
- for(String line: lines) {
74
-
75
- fOut.write(line);
76
-
77
- fOut.newLine();
78
-
79
- }
80
82
 
81
83
  }
82
84