util
Class StreamMarker
java.lang.Object
util.StreamMarker
- All Implemented Interfaces:
- Serializable
- public final class StreamMarker
- extends Object
- implements Serializable
An Object to mark positions in ObjectStreams.
You can use a StreamMarker to mark the end of a flow of objects of
unknown class and unknown size. On reading you will then know exactly up to
where you must read.
E.g. to store some objects out of an enumeration and reread them into a
vector you could use code similar to the following:
...
Enumeration e = q.elements();
ObjectOutputStream o = new ObjectOutputStream (fileOutputStream);
while (e.hasMoreElements())
o.writeObject (e.nextElement());
// Set the Marker:
o.writeObject (new StreamMarker());
...
Vector v = new Vector();
ObjectInputStream oi = new ObjectInputStream (fileInputStream);
Object ob = oi.readObject();
while (!(ob instanceof StreamMarker)) {
v.addElement (ob);
ob = oi.readObject();
}
...
- Since:
- v1.0
- Author:
- Steffen Zschaler
- See Also:
- Serialized Form
Constructor Summary |
StreamMarker()
Create a new StreamMarker. |
Method Summary |
String |
toString()
Give a string representation of this object. |
StreamMarker
public StreamMarker()
- Create a new StreamMarker.
toString
public final String toString()
- Give a string representation of this object.
- Override:
- Never