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 1
1
package com .codefortomorrow .advanced .chapter14 .examples ;
2
+
2
3
import java .io .*;
3
4
4
5
public class TryWithResources {
5
6
6
7
public static void main (String [] args ) throws IOException {
7
8
File file = new File ("names.txt" );
8
9
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
+ ) {
12
14
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
+ );
16
18
} catch (IOException e ) {
17
19
System .out .println ("An IO Exception occurred." );
18
- e .printStackTrace (); // Prints error output stream.
20
+ e .printStackTrace (); // Prints error output stream.
19
21
}
20
22
}
21
23
}
You can’t perform that action at this time.
0 commit comments