Specifications
Sun Services
Java™ Programming Language
Module 9, slide 24 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
File Output Example
18
19 System.out.print("Enter file text. ");
20 System.out.println("[Type ctrl-d to stop.]");
21
22 // Read each input line and echo it to the screen.
23 while ((s = in.readLine()) != null) {
24 out.println(s);
25 }
26
27 // Close the buffered reader and the file print writer.
28 in.close();
29 out.close();
30
31 } catch (IOException e) {
32 // Catch any IO exceptions.
33 e.printStackTrace();
34 }
35 }
36 }










