edu.rit.m2mp
Class MessageOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by edu.rit.m2mp.MessageOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class MessageOutputStream
extends OutputStream

Class MessageOutputStream provides an output stream for writing the contents of an outgoing Many-to-Many Protocol (M2MP) message. A message output stream is not constructed directly. Rather, it is obtained by calling the createOutgoingMessage() method in class M2MP.


Method Summary
 void close()
          Close this message output stream.
 void flush()
          Flush this message output stream.
 void write(byte[] buf)
          Write the given byte array to this message output stream.
 void write(byte[] buf, int off, int len)
          Write a portion of the given byte array to this message output stream.
 void write(int b)
          Write the given byte to this message output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

write

public void write(int b)
           throws IOException
Write the given byte to this message output stream. The least significant 8 bits of the byte are written.

Specified by:
write in class OutputStream
Parameters:
b - Byte.
Throws:
IOException - Thrown if an I/O error occurred.

write

public void write(byte[] buf)
           throws IOException
Write the given byte array to this message output stream.

Overrides:
write in class OutputStream
Parameters:
buf - Byte array.
Throws:
NullPointerException - (unchecked exception) Thrown if buf is null.
IOException - Thrown if an I/O error occurred.

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws IOException
Write a portion of the given byte array to this message output stream. The bytes stored at buf[off] through buf[off+len-1] inclusive are written.

Overrides:
write in class OutputStream
Parameters:
buf - Byte array.
off - Index of the first byte to write.
len - Number of bytes to write.
Throws:
NullPointerException - (unchecked exception) Thrown if buf is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if off < 0, len < 0, or off+len > buf.length.
IOException - Thrown if an I/O error occurred.

flush

public void flush()
           throws IOException
Flush this message output stream.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException - Thrown if an I/O error occurred.

close

public void close()
           throws IOException
Close this message output stream.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException - Thrown if an I/O error occurred.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.