edu.mit.csail.aeolus.api
Class AeolusFileOutputStream

java.lang.Object
  extended by edu.mit.csail.aeolus.api.AeolusFileOutputStream

public class AeolusFileOutputStream
extends java.lang.Object

An Aeolus file output stream can be used for writing data to a given file.

The stream will only be created and opened if the requester labels allow writing to the file.

The file stream buffers all the writes. Closing the file stream causes data to be actually written to the file.

If the caller labels change and no longer allow the write, the stream will be closed and any data previously written to the stream will be written to the file.


Constructor Summary
AeolusFileOutputStream(java.lang.String hostname, java.lang.String filePath, boolean appendMode)
          Creates a filestream for writing to the file specified by filePath on hostname
 
Method Summary
 void close()
          Closes the file stream.
 void write(byte[] buffer)
          Writes buffer.length bytes to the stream from the given buffer.
 void write(byte[] buffer, int offset, int count)
          Writes count bytes into the stream from the buffer starting at the given offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AeolusFileOutputStream

public AeolusFileOutputStream(java.lang.String hostname,
                              java.lang.String filePath,
                              boolean appendMode)
                       throws AeolusException,
                              java.io.FileNotFoundException,
                              java.io.IOException
Creates a filestream for writing to the file specified by filePath on hostname

Parameters:
hostname - - node where the file is stored
filePath - - path to the file on hostname
appendMode - - if set to true, the bytes will be written to the end of the file
Throws:
InfoFlowControlException - - if caller labels don't allow writing to the file or reading from a parent directory if the file is missing
java.io.FileNotFoundException - - if the file does not exist on the hostname
AeolusException - - if a FileSystemClient can not be created
java.io.IOException - - if an I/O error occurs while opening the file stream (e.g. when retrieving file labels)
Method Detail

close

public void close()
           throws java.io.IOException,
                  AeolusException
Closes the file stream. Any subsequent operations on this stream will fail with an IOException.

Throws:
java.io.IOException - - if an I/O error occurs while writing the data to the file or the file is already closed
AeolusException

write

public void write(byte[] buffer)
           throws java.io.IOException,
                  InfoFlowControlException,
                  AeolusException
Writes buffer.length bytes to the stream from the given buffer.

Parameters:
buffer - - byte array storing the data to be written
Throws:
java.io.IOException - - if an I/O error occurred while writing to the stream (e.g. the stream has been closed)
InfoFlowControlException - - if caller labels no longer allow writing to the file
AeolusException

write

public void write(byte[] buffer,
                  int offset,
                  int count)
           throws java.io.IOException,
                  InfoFlowControlException,
                  AeolusException
Writes count bytes into the stream from the buffer starting at the given offset.

Throws:
java.io.IOException - - if an I/O error occurred while writing to the stream (e.g. the stream has been closed)
InfoFlowControlException - - if caller labels no longer allow writing to the file
AeolusException