home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 933 b | 31 lines |
-
- import java.io.*;
-
- public class BufferedWriteCharStream
- {
- // This program runs as an application
- public static void main(String[] arguments)
- {
- //Create an array of data to print
- char[] allChars = {'H','e','l','l','o',' ','W','o','r','l','d','\n'};
- try
- {
- //declare a stream and attach it to a file
- FileWriter ofile = new FileWriter("bufChar.dat");
-
- //declare a BufferedWriter - attach it to a stream
- BufferedWriter bufStream = new BufferedWriter(ofile);
-
- for (int i=0; i < allChars.length; i++)
- //write to the char stream
- bufStream.write(allChars[i]);
- bufStream.close();
- } catch (IOException e)// handle any errors
- {
- System.out.println("Error - " + e.toString());
- }//catch
- }//main
- }//BufferedWriteCharStream
-
-
-