Example #1
0
  /** Recycle the output buffer. */
  public void recycle() {

    state = INITIAL_STATE;

    // If usage of mark made the buffer too big, reallocate it
    if (cb.getChars().length > size) {
      cb = new CharChunk(size);
      cb.setLimit(size);
      cb.setOptimizedWrite(false);
      cb.setCharInputChannel(this);
      cb.setCharOutputChannel(this);
    } else {
      cb.recycle();
    }
    markPos = -1;
    bb.recycle();
    closed = false;

    if (conv != null) {
      conv.recycle();
    }

    gotEnc = false;
    enc = null;
  }
Example #2
0
  /**
   * Alternate constructor which allows specifying the initial buffer size.
   *
   * @param size Buffer size to use
   */
  public InputBuffer(int size) {

    this.size = size;
    bb = new ByteChunk(size);
    bb.setLimit(size);
    bb.setByteInputChannel(this);
    cb = new CharChunk(size);
    cb.setLimit(size);
    cb.setOptimizedWrite(false);
    cb.setCharInputChannel(this);
    cb.setCharOutputChannel(this);
  }