uk.ac.rdg.resc.jstyx.client
Class CStyxFileOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by uk.ac.rdg.resc.jstyx.client.CStyxFileOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class CStyxFileOutputStream
extends java.io.OutputStream

Output stream for writing data to a Styx File. The file will be truncated at the end of the data that are written through this class.

Author:
Jon Blower $Revision: 507 $ $Date: 2005-12-01 08:21:56 +0000 (Thu, 01 Dec 2005) $ $Log$ Revision 1.4 2005/12/01 08:21:55 jonblower Fixed javadoc comments Revision 1.3 2005/10/14 18:04:33 jonblower Fixed bug with not updating file offset, and added code to write zero bytes to signify EOF Revision 1.2 2005/09/01 17:12:10 jonblower Changes to Input and Output stream code Revision 1.1 2005/08/31 17:03:18 jonblower Renamed "StyxFile*putStream*" to "CStyxFile*putStream*" for consistency with CStyxFile class Revision 1.4 2005/05/23 16:48:17 jonblower Overhauled CStyxFile (esp. asynchronous methods) and StyxConnection (added cache of CStyxFiles) Revision 1.3 2005/05/12 07:40:52 jonblower CStyxFile.close() no longer throws a StyxException Revision 1.2 2005/03/16 17:55:53 jonblower Replaced use of java.nio.ByteBuffer with MINA's ByteBuffer to minimise copying of buffers Revision 1.1.1.1 2005/02/16 18:58:19 jonblower Initial import

Constructor Summary
CStyxFileOutputStream(CStyxFile file)
          Creates a new CStyxFileOutputStream to write data to the given CStyxFile.
CStyxFileOutputStream(CStyxFile file, boolean closeConnectionWhenCloseStream)
          Creates a new CStyxFileOutputStream to write data to the given CStyxFile.
 
Method Summary
 void close()
          Closes the file stream (i.e.
 void flush()
          Flushes the internal buffer and forces any buffered output bytes to be written
 void write(int b)
          Writes the specified byte to the Styx file.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CStyxFileOutputStream

public CStyxFileOutputStream(CStyxFile file,
                             boolean closeConnectionWhenCloseStream)
                      throws StyxException
Creates a new CStyxFileOutputStream to write data to the given CStyxFile. If the file already exists it will be overwritten.

Parameters:
file - the file to write to
closeConnectionWhenCloseStream - If this is true, we shall close the underlying StyxConnection when this stream is closed (this is normally set when getting an output stream through the StyxURLConnection class)
Throws:
StyxException

CStyxFileOutputStream

public CStyxFileOutputStream(CStyxFile file)
                      throws StyxException
Creates a new CStyxFileOutputStream to write data to the given CStyxFile. If the file already exists it will be overwritten.

Throws:
StyxException
Method Detail

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to the Styx file. Must call flush() to guarantee that the byte is actually written, as it may be held in a buffer.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Flushes the internal buffer and forces any buffered output bytes to be written

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the file stream (i.e. clunks the fid of the underlying file) and flushes any remaining data to the file.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.