/*
 * Java Network Programming, Second Edition
 * Merlin Hughes, Michael Shoffner, Derek Hamner
 * Manning Publications Company; ISBN 188477749X
 *
 * http://nitric.com/jnp/
 *
 * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner;
 * all rights reserved; see license.txt for details.
 */

import java.io.*;

public class ResettingByteArrayOutputStream extends ByteArrayOutputStream {
  public ResettingByteArrayOutputStream () {
  }
  
  public ResettingByteArrayOutputStream (int initialCapacity) {
    super (initialCapacity);
  }
  
  public synchronized byte[] toByteArray () {
    byte[] result = super.toByteArray ();
    reset ();
    return result;
  }
  
  public synchronized void writeTo (OutputStream out) throws IOException {
    super.writeTo (out);
    reset ();
  }
}
