/* (non-Javadoc)
@see java.io.OutputStream#write(byte[], int, int)
186959
@Override
    public void write(byte[] b, int off, int len) throws IOException
    {
        int wbytes = len;
        int offset = off;
        
        while( wbytes > 0 )
        {
            if ( buf.position() >= buf.capacity() )
            {
                flush();
            }
            
            int length = Math.min( wbytes, buf.limit() - buf.position() );
            
            buf.put(b, offset, length);
            
            offset += length;
            wbytes -= length;
        }
    }
1171711
@Override
    public void write(int value) throws IOException {
        validate();
        byte[] buf = new byte[1];
        buf[0] = (byte) value;
        writeToBuffers(buf, 0, 1);

    }
380968
@Override
	public void write(byte[] b, int off, int len) throws PacketException {
		baq.add(b, off, len);
		while (packetSize > 0 || (packetSize = parser.getSize(baq.array(),
				baq.offset(), baq.length())) > 0) {
			if (baq.length() < packetSize) {
				return;
			}
			consumer.accept(baq.array(), baq.offset(), packetSize);
			baq.remove(packetSize);
			packetSize = 0;
		}
	}
918871
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    if (buf == null)
      throw new NullPointerException();
    else if (offset < 0 || buf.length < offset + length)
      throw new ArrayIndexOutOfBoundsException();

    nativeWrite(_fd, buf, offset, length);
  }
587131
@Override
    public void write(byte[] b, int offset, int length) throws IOException {
        if (length == 0) {
            return;
        }
        int newcount = count + length;
        if (newcount > buf.length) {
            buf = Arrays.copyOf(buf, oversize(newcount));
        }
        System.arraycopy(b, offset, buf, count, length);
        count = newcount;
    }
343744
@Override
    public void write(byte bbuf[], int off, int len) throws IOException {
    	for(OutputStream os : oss) {
    		os.write(bbuf,off,len);
    	}
    }
854993
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    while (offset < length) {
      TempBuffer tail = _tail;
      
      if (tail == null || tail.buffer().length <= tail.length()) {
        addBuffer(TempBuffer.create());
        tail = _tail;
      }
      
      int tailLength = tail.length();
      
      
      byte []tailBuffer = tail.buffer();

      int sublen = tailBuffer.length - tailLength;
      if (length - offset < sublen) {
        sublen = length - offset;
      }

      System.arraycopy(buf, offset, tailBuffer, tailLength, sublen);

      offset += sublen;
      tail.length(tailLength + sublen);
    }
  }
1277023
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    if (! _isPost) {
      return;
    }

    if (_tempStream == null) {
      _tempStream = new MemoryStream();
    }

    _tempStream.write(buf, offset, length, isEnd);
  }
824039
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    OutputStream stream = getStream();

    if (stream == null) {
      return;
    }

    synchronized (stream) {
      stream.write(buf, offset, length);
      
      if (isEnd) {
        stream.flush();
      }
    }
  }
979318
@Override
  public void write(int v)
    throws IOException
  {
    _buf[0] = (byte) v;
    
    _stream.write(_buf, 0, 1, false);
  }
371783
@Override
  public void write(int b) throws IOException {
    if (!writtenHeader) {
      writeHeader();
      writtenHeader = true;
    }
    cipherStream.write(b);
  }
428204
@Override
  public void write(byte[] buffer, int offset, int length)
  {
    try {
      OutputStream os = _os;

      if (os != null) {
        os.write(buffer, offset, length);
      }
    } catch (Exception e) {
      log.log(Level.FINER, e.toString(), e);
    }
  }
1132974
public void write(byte[]b,int o,int l)
        throws IOException
    {
        _out.write(b,o,l);
    }
782503
@Override
  public void write(byte []buffer, int offset, int length)
  {
    write(buffer, offset, length, true);
  }
441030
@Override
  public void write(byte []buffer, int offset, int length)
    throws IOException
  {
    _stream.write(buffer, offset, length, false);
  }
1302519
@Override
    public synchronized void write(byte[] b, int off, int len) throws IOException {
        super.write(b, off, len);
        this.branch.write(b, off, len);
    }
282504
public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());

    TempOutputStream ts = new TempOutputStream();
    //ts.openWrite();
    //WriteStream ws = new WriteStream(ts);
    ByteCodeWriter o2 = new ByteCodeWriter(ts, out.getJavaClass());

    o2.writeShort(_exceptions.size());
    for (int i = 0; i < _exceptions.size(); i++) {
      String exn = _exceptions.get(i);

      o2.writeClass(exn);
    }
    
    ts.close();
    
    out.writeInt(ts.getLength());
    
    TempBuffer ptr = ts.getHead();

    for (; ptr != null; ptr = ptr.next())
      out.write(ptr.buffer(), 0, ptr.length());

    ts.destroy();
  }