net.rim.device.api.io
Class SharedOutputStream

java.lang.Object
  |
  +--net.rim.device.api.io.SharedOutputStream

public class SharedOutputStream
extends Object

Output stream that can share its stream data with a number of writers.

Use this class when you want multiple people writing to the same output stream, and have the output in a specific order, but you cannot control the order that they write in. For example, in a MIME Stream, you can have multiple parts, which appear in a specific order, but the user can write to the individual parts in any particular order.


Constructor Summary
SharedOutputStream(OutputStream out)
          Build a shared output stream on provided output stream.
 
Method Summary
 void close()
          Closes this output stream and releases any system resources it uses.
 OutputStream getOutputStream()
          Retrieves a new output stream that can write to this shared stream.
 void writeSeparator()
          Invoked after an output stream is closed and before the next one begins to write to the shared stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedOutputStream

public SharedOutputStream(OutputStream out)
Build a shared output stream on provided output stream.

Parameters:
out - Output stream to use as underlying data buffer for this stream.
Method Detail

close

public void close()
           throws IOException
Closes this output stream and releases any system resources it uses.

A closed stream cannot perform output operations, and it cannot be re-opened.

Throws:
IOException - If an I/O error occurs.

getOutputStream

public OutputStream getOutputStream()
Retrieves a new output stream that can write to this shared stream.

Returns:
Output stream that can write to this shared stream.

writeSeparator

public void writeSeparator()
                    throws IOException
Invoked after an output stream is closed and before the next one begins to write to the shared stream. The default writeSeparator does nothing. It is up to an extending subclass to implement the appropriate behaviour. Invoked after an output stream is closed and before the next one begins to write to the shared stream.

Throws:
IOException - If an I/O error occurs.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.