Package ec.util

Class DataPipe

java.lang.Object
ec.util.DataPipe

public class DataPipe extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The input stream
    The output stream
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    A poor-man's clone for serializable but not cloneable objects: serializes an object to the pipe, then deserializes it.
    int
    Returns the number of elements read from the buffer so far (after the last reset()).
    int
    Returns the number of elements written to the buffer so far (after the last reset()).
    void
    Reset the buffer.
    int
    Returns the total size of the buffer.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • DataPipe

      public DataPipe()
  • Method Details

    • 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 Object copy(Serializable obj) throws IOException, ClassNotFoundException
      A poor-man's clone for serializable but not cloneable objects: serializes an object to the pipe, then deserializes it.
      Throws:
      IOException
      ClassNotFoundException
    • toString

      public String toString()
      Overrides:
      toString in class Object