Specifications
Sun Services
Java™ Programming Language
Module 9, slide 22 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
File Stream I/O
14 // Read each line from the file and echo it to the screen.
15 s = in.readLine();
16 while ( s != null ) {
17 System.out.println("Read: " + s);
18 s = in.readLine();
19 }
20 // Close the buffered reader
21 in.close();
22
23 } catch (FileNotFoundException e1) {
24 // If this file does not exist
25 System.err.println("File not found: " + file);
26
27 } catch (IOException e2) {
28 // Catch any other IO exceptions.
29 e2.printStackTrace();
30 }
31 }
32 }










