Skip to content

Commit 1ed2258

Browse files
committed
Adding limited version of processFile method
1 parent 6ec8a0f commit 1ed2258

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/lambdasinaction/chap3/ExecuteAround.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
public class ExecuteAround {
55

66
public static void main(String ...args) throws IOException{
7+
8+
// method we want to refactor to make more flexible
9+
String result = processFileLimited();
10+
System.out.println(result);
11+
12+
System.out.println("---");
13+
714
String oneLine = processFile((BufferedReader b) -> b.readLine());
815
System.out.println(oneLine);
916

@@ -12,6 +19,14 @@ public static void main(String ...args) throws IOException{
1219

1320
}
1421

22+
public static String processFileLimited() throws IOException {
23+
try (BufferedReader br =
24+
new BufferedReader(new FileReader("lambdasinaction/chap3/data.txt"))) {
25+
return br.readLine();
26+
}
27+
}
28+
29+
1530
public static String processFile(BufferedReaderProcessor p) throws IOException {
1631
try(BufferedReader br = new BufferedReader(new FileReader("lambdasinaction/chap3/data.txt"))){
1732
return p.process(br);

0 commit comments

Comments
 (0)