File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/java/lambdasinaction/chap3 Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 44public 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 );
You can’t perform that action at this time.
0 commit comments