home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 1.1 KB | 35 lines |
-
- import java.io.*;
-
- public class BufferedWriteDataStream
- {
- // This program runs as an application
- public static void main(String[] arguments)
- {
- //Create an array of data to print
- double[] allDoubles = {1.1,3.1,5.1,7.1,9.1,11.1,13.1,15.1,17.1,19.1,21.1,23.1,25.1,27.1,29.1};
- try
- {
- //declare a stream and attach it to a file
- FileOutputStream ofile = new FileOutputStream("bufDouble.dat");
-
- //declare a buffer and attach it to a stream
- BufferedOutputStream bufStream = new BufferedOutputStream(ofile);
-
- //declare a data stream and assign it to a buffer
- DataOutputStream datStream = new DataOutputStream(bufStream);
-
- for (int i=0; i < allDoubles.length; i++)
- //write to the datastream
- datStream.writeDouble(allDoubles[i]);
- datStream.close();
- } catch (IOException e)// handle any errors
- {
- System.out.println("Error - " + e.toString());
- }//catch
- }//main
- }//BufferedWriteDataStream
-
-
-
-