1 /* 2 * File: TextOutputTest.java 3 * 4 * Character stream output with Writer classes 5 * 6 * Copyright: Northeast Parallel Architectures Center 7 * 8 */ 9 10 import java.io.IOException; 11 import java.io.FileWriter; 12 import java.io.PrintWriter; 13 14 public class TextOutputTest { 15 16 public static void main( String args[] ) throws IOException { 17 18 String filename = "TextIOTest.dat"; 19 20 String address[] = { 21 "Northeast Parallel Architectures Center", 22 "111 College Place", 23 "Syracuse University", 24 "Syracuse, NY 13244-4100" 25 }; 26 27 PrintWriter out = 28 new PrintWriter( 29 new FileWriter( filename ) ); // a character stream 30 31 System.out.println( "Writing..." ); 32 for ( int i = 0; i < address.length; i++ ) { 33 out.println( address[i] ); 34 } 35 36 out.close(); 37 38 } 39 40 }