ec.util
Class DataPipe
- java.lang.Object
-
- ec.util.DataPipe
-
public class DataPipe extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field and Description java.io.DataInputStreaminputThe input streamjava.io.DataOutputStreamoutputThe output stream
-
Constructor Summary
Constructors Constructor and Description DataPipe()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static java.lang.Objectcopy(java.io.Serializable obj)A poor-man's clone for serializable but not cloneable objects: serializes an object to the pipe, then deserializes it.intnumRead()Returns the number of elements read from the buffer so far (after the last reset()).intnumWritten()Returns the number of elements written to the buffer so far (after the last reset()).voidreset()Reset the buffer.intsize()Returns the total size of the buffer.java.lang.StringtoString()
-
-
-
Field Detail
-
input
public java.io.DataInputStream input
The input stream
-
output
public java.io.DataOutputStream output
The output stream
-
-
Method Detail
-
reset
public void reset()
Reset the buffer. Does not resize it back to a smaller size -- if it has ballooned it will stay large, though it will no longer have wasted space in it. If you wish to make the buffer a more manageable size, create a new DataPipe instead.
-
size
public int size()
Returns the total size of the buffer.
-
numWritten
public int numWritten()
Returns the number of elements written to the buffer so far (after the last reset()).
-
numRead
public int numRead()
Returns the number of elements read from the buffer so far (after the last reset()).
-
copy
public static java.lang.Object copy(java.io.Serializable obj) throws java.io.IOException, java.lang.ClassNotFoundExceptionA poor-man's clone for serializable but not cloneable objects: serializes an object to the pipe, then deserializes it.- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG