|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
org.jnetstream.capture.PacketOutputStream
public class PacketOutputStream
A PacketOutputStream writes
CapturePacket objects to an OutputStream. The
Packet objects can be read (reconstituted) using an
PacketInputStream.
Persistent storage of CapturePackets can be accomplished by using a file for
a stream. If the stream is a network socket stream, the CapturePackets can be
reconstitued on a nother host or in another process.
Here is an example:
FileOutputStream fos = new FileOutputStream("test.stream");
PacketOutputStream cos = new PacketOutputStream(fos);
CapturePacket packet = // gotten from live network or file
cos.writePacket(packet);
cos.close();
FileInputStream fis = new FileInputStream("test.stream", "r");
PacketInputStream cis = new PacketInputStream(fis);
packet = cis.readPacket();
cis.close();
| Field Summary | |
|---|---|
protected java.io.ObjectOutputStream |
out
|
| Constructor Summary | |
|---|---|
protected |
PacketOutputStream()
Provide a way for subclasses that are completely reimplementing CapturePacketOutputStream to not have to allocate private data just used by this implementation of CaptureOutputOutputStream. |
|
PacketOutputStream(java.io.OutputStream out)
Creates a new capture output stream bound to the supplied output stream. |
| Method Summary | |
|---|---|
void |
close()
Closes the output stream. |
void |
flush()
Flushes any buffered changes from this output stream to the underlying stream immediately. |
void |
write(byte[] b)
Write the byte array into the underlying outputstream. |
void |
write(byte[] b,
int off,
int len)
Writes the byte array into the underlying outputstream |
void |
write(int b)
Writes a single byte to the output stream. |
void |
writePacket(Packet packet)
Serializes and writes a packet to the output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.ObjectOutputStream out
| Constructor Detail |
|---|
protected PacketOutputStream()
Provide a way for subclasses that are completely reimplementing CapturePacketOutputStream to not have to allocate private data just used by this implementation of CaptureOutputOutputStream.
public PacketOutputStream(java.io.OutputStream out)
throws java.io.IOException
out - underlying output stream this object is bound to
java.io.IOException - any IO errors during transmittion| Method Detail |
|---|
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.OutputStreamjava.io.IOException
public void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreamb - byte array to writeoff - offset into the byte array to start reading the datalen - number of bytes to write from the byte array to outputstream
java.io.IOException - any IO errors
public void write(byte[] b)
throws java.io.IOException
write in class java.io.OutputStreamb - the byte array to write to the outputstream in its entirety
java.io.IOException - any IO errors
public void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamb - the byte, in form of an integer, to write to the stream
java.io.IOException - any IO errors
public void writePacket(Packet packet)
throws java.io.IOException
writePacket in interface CapturePacketOutput<Packet>packet - the packet to serialize and write out to the outputstream
java.io.IOException - any of the usual Input/Output related exceptionscom.slytechs.capture.stream.CapturePacketOutput#writePacket(com.slytechs.capture.CapturePacket)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||