File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
src/com/codefortomorrow/advanced/chapter14/examples Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 11package com .codefortomorrow .advanced .chapter14 .examples ;
2+
23import java .io .*;
34
45public class TryWithResources {
56
67 public static void main (String [] args ) throws IOException {
78 File file = new File ("names.txt" );
89
9- try (FileInputStream in = new FileInputStream (file );
10- FileOutputStream out = new FileOutputStream ("names_upper.txt" )) {
11-
10+ try (
11+ FileInputStream in = new FileInputStream (file );
12+ FileOutputStream out = new FileOutputStream ("names_upper.txt" )
13+ ) {
1214 int c ;
13- while ((c = in .read ()) != -1 )
14- out . write ( Character .toUpperCase ((char )c ));
15-
15+ while ((c = in .read ()) != -1 ) out . write (
16+ Character .toUpperCase ((char ) c )
17+ );
1618 } catch (IOException e ) {
1719 System .out .println ("An IO Exception occurred." );
18- e .printStackTrace (); // Prints error output stream.
20+ e .printStackTrace (); // Prints error output stream.
1921 }
2022 }
2123}
You can’t perform that action at this time.
0 commit comments