Writing data to Files

The java.io.FileOutputStream class represents an OutputStream that writes bytes to a file. It has the following public methods:

 public FileOutputStream(String name) throws IOException
 public FileOutputStream(String name, boolean append)
  throws IOException
 public FileOutputStream(File file) throws IOException
 public FileOutputStream(FileDescriptor fd)
 
 public void write(int b) throws IOException
 public void write(byte[] data) throws IOException
 public void write(byte[] data, int offset, int length)
  throws IOException
 
 public void close() throws IOException
 public final FileDescriptor getFD() throws IOException

Except for the constructors and getFD(), these methods merely override the methods of the same name in java.io.OutputStream. You use them exactly like you use those methods, only the output is written into a file.


Previous | Next | Top | Cafe au Lait

Copyright 1997, 1999, 2002 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified October 23, 2002