Writes as many continuation frames as needed until {@code padding} and {@code headerBlock} are consumed.
192505
private ChannelFuture writeContinuationFrames(ChannelHandlerContext ctx, int streamId,
            ByteBuf headerBlock, int padding, SimpleChannelPromiseAggregator promiseAggregator) {
        Http2Flags flags = new Http2Flags().paddingPresent(padding > 0);
        int maxFragmentLength = maxFrameSize - padding;
        // TODO: same padding is applied to all frames, is this desired?
        if (maxFragmentLength <= 0) {
            return promiseAggregator.setFailure(new IllegalArgumentException(
                    "Padding [" + padding + "] is too large for max frame size [" + maxFrameSize + "]"));
        }

        if (headerBlock.isReadable()) {
            // The frame header (and padding) only changes on the last frame, so allocate it once and re-use
            int fragmentReadableBytes = min(headerBlock.readableBytes(), maxFragmentLength);
            int payloadLength = fragmentReadableBytes + padding;
            ByteBuf buf = ctx.alloc().buffer(CONTINUATION_FRAME_HEADER_LENGTH);
            writeFrameHeaderInternal(buf, payloadLength, CONTINUATION, flags, streamId);
            writePaddingLength(buf, padding);

            do {
                fragmentReadableBytes = min(headerBlock.readableBytes(), maxFragmentLength);
                ByteBuf fragment = headerBlock.readRetainedSlice(fragmentReadableBytes);

                payloadLength = fragmentReadableBytes + padding;
                if (headerBlock.isReadable()) {
                    ctx.write(buf.retain(), promiseAggregator.newPromise());
                } else {
                    // The frame header is different for the last frame, so re-allocate and release the old buffer
                    flags = flags.endOfHeaders(true);
                    buf.release();
                    buf = ctx.alloc().buffer(CONTINUATION_FRAME_HEADER_LENGTH);
                    writeFrameHeaderInternal(buf, payloadLength, CONTINUATION, flags, streamId);
                    writePaddingLength(buf, padding);
                    ctx.write(buf, promiseAggregator.newPromise());
                }

                ctx.write(fragment, promiseAggregator.newPromise());

                // Write out the padding, if any.
                if (paddingBytes(padding) > 0) {
                    ctx.write(ZERO_BUFFER.slice(0, paddingBytes(padding)), promiseAggregator.newPromise());
                }
            } while (headerBlock.isReadable());
        }
        return promiseAggregator;
    }
1124258
public WsByteBuffer[] buildFrameArrayForWrite() {
        WsByteBuffer[] output;

        int headerSize = SIZE_FRAME_BEFORE_PAYLOAD;
        if (PADDED_FLAG) {
            headerSize = SIZE_FRAME_BEFORE_PAYLOAD + 1;
        }
        WsByteBuffer frameHeaders = getBuffer(headerSize);
        byte[] frame;
        if (frameHeaders.hasArray()) {
            frame = frameHeaders.array();
        } else {
            frame = super.createFrameArray();
        }

        // add the first 9 bytes of the array
        setFrameHeaders(frame, utils.FRAME_TYPE_DATA);

        // set up the frame payload
        int frameIndex = SIZE_FRAME_BEFORE_PAYLOAD;

        // add pad length field
        if (PADDED_FLAG) {
            utils.Move8BitstoByteArray(paddingLength, frame, frameIndex);
            frameIndex++;
        }
        frameHeaders.put(frame, 0, headerSize);
        frameHeaders.flip();

        // create padding and put in return buffer array
        if (PADDED_FLAG) {
            WsByteBuffer padding = getBuffer(paddingLength);
            for (int i = 0; i < paddingLength; i++) {
                padding.put((byte) 0);
            }
            padding.flip();
            output = new WsByteBuffer[3];
            output[0] = frameHeaders;
            output[1] = dataBuffer;
            output[2] = padding;
        }
        // create the output buffer array
        else {
            output = new WsByteBuffer[2];
            output[0] = frameHeaders;
            output[1] = dataBuffer;
        }
        return output;
    }
1012773
private void writeBytesSlow(final byte[] bytes, int off, int len)
    {
        while (len > 0)
        {
            final Block block = current;
            final int amount = Math.min(len, block.remaining());
            System.arraycopy(bytes, off, block.data, block.limit, amount);
            block.limit += amount;
            off += amount;
            len -= amount;
            if (block.remaining() == 0)
            {
                if (index == blocks.size() - 1)
                {
                    allocateNewBlock();
                }
                index++;
                current = blocks.get(index);
            }
        }

    }
207554
private ListenableFuture<?> writeBlocksToTargets(Collection<DBBPool.BBContainer> outputBuffers,
                                                     int[] serialized)
    {
        Preconditions.checkArgument(m_tableTasks.size() == serialized.length);
        Preconditions.checkArgument(outputBuffers.size() == serialized.length);

        final List<ListenableFuture<?>> writeFutures =
            new ArrayList<ListenableFuture<?>>(outputBuffers.size());

        // The containers, the data targets, and the serialized byte counts should all line up
        Iterator<DBBPool.BBContainer> containerIter = outputBuffers.iterator();
        int serializedIndex = 0;

        for (SnapshotTableTask task : m_tableTasks) {
            final DBBPool.BBContainer container = containerIter.next();

            /*
             * Finalize the buffer by setting position to 0 and limit to the last used byte
             */
            final ByteBuffer buf = container.b();
            buf.limit(serialized[serializedIndex++] + task.m_target.getHeaderSize());
            buf.position(0);

            Callable<DBBPool.BBContainer> valueForTarget = Callables.returning(container);
            if (task.m_filters != null) {
                for (SnapshotDataFilter filter : task.m_filters) {
                    valueForTarget = filter.filter(valueForTarget);
                }
            }

            ListenableFuture<?> writeFuture = task.m_target.write(valueForTarget, m_tableId);
            if (writeFuture != null) {
                writeFutures.add(writeFuture);
            }
        }

        // Wraps all write futures in one future
        return Futures.allAsList(writeFutures);
    }
471458
public void writeTo(final OutputStream out) throws IOException
    {
        for (int i = 0; i <= index; i++)
        {
            Block block = blocks.get(i);
            out.write(block.data, 0, block.limit);
        }
    }
1085348
private void prepareForWrite(long pos, long len) throws IOException {
    long end = pos + len;

    // allocate any additional blocks needed
    int lastBlockIndex = blockCount - 1;
    int endBlockIndex = blockIndex(end - 1);

    if (endBlockIndex > lastBlockIndex) {
      int additionalBlocksNeeded = endBlockIndex - lastBlockIndex;
      disk.allocate(this, additionalBlocksNeeded);
    }

    // zero bytes between current size and pos
    if (pos > size) {
      long remaining = pos - size;

      int blockIndex = blockIndex(size);
      byte[] block = blocks[blockIndex];
      int off = offsetInBlock(size);

      remaining -= zero(block, off, length(off, remaining));

      while (remaining > 0) {
        block = blocks[++blockIndex];

        remaining -= zero(block, 0, length(remaining));
      }

      size = pos;
    }
  }
893379
private void writeEndMark() throws IOException {
    intLEBuffer.putInt(0, 0);
    out.write(intLEBuffer.array());
    if (frameInfo.isEnabled(FLG.Bits.CONTENT_CHECKSUM)) {
      intLEBuffer.putInt(0, frameInfo.currentStreamHash());
      out.write(intLEBuffer.array());
    }
    frameInfo.finish();
  }
1129575
def start_write(self, frame, node=None):
        """"""
        if frame.buffer is None:
            self.writeline('yield ', node)
        else:
            self.writeline('%s.append(' % frame.buffer, node)
372739
public void writeByteCurrentPosition(byte v) throws IOException {
    int index = (int)(position - bufferOffset);
    if (index < maxBufferSize) {
      buffer[index] = v;
      isByte[index] = true;
      if (index + 1 > currentBufferSize) currentBufferSize = index + 1;
      if (index + 1 >= maxBufferSize) {
        writeBuffer();
        newBuffer(position + 1);
      }
    } else {
      aFile.write(v);
    }
    position++;
  }
1156083
public synchronized void write(int blockNumber, int blockOffset, int value) 
			throws IOException {
		long pointer = getBlockOffset(blockNumber) + blockOffset;
		if(mapped == true) {
			MappedByteBuffer map = NikeFS2FileAccessMonitor.instance().requestMap(this);
			map.position((int)pointer);
			map.put((byte)(value - 128));
		} else {
			rafile.seek(pointer);
			rafile.write(value);
		}
	}
628564
public void completeFrame() throws IOException {
        int frameSize = buffer.position();
        if (frameSize > 0) {
            frameSizeBuffer.rewind();
            try (ByteBufferOutputStream bos = new ByteBufferOutputStream(frameSizeBuffer);
                 BinaryWriter writer = new BigEndianBinaryWriter(bos)) {
                writer.writeInt(frameSize);
                bos.flush();
            }
            frameSizeBuffer.flip();
            buffer.flip();

            synchronized (out) {
                out.write(frameSizeBuffer);
                while (buffer.hasRemaining()) {
                    out.write(buffer);
                }
            }

            buffer.rewind();
            buffer.limit(buffer.capacity());
        }
    }
476401
public void write(final byte[] srcBytes, final int srcOffset, final int length)
    {
        final long resultingOffset = position + ((long)length);
        if (resultingOffset > this.length)
        {
            throw new IllegalStateException("insufficient capacity in the buffer");
        }

        buffer.putBytes(offset + position, srcBytes, srcOffset, length);
        position += length;
    }
115700
public void writeContent(final OutputStream result) throws IOException
    {
        Iterator it = this.borders.values().iterator();
        while(it.hasNext()) {
            ((RtfBorder) it.next()).writeContent(result);
        }
    }
44451
public boolean write(byte []buffer, int offset, int length)
  {
    if (length == 0) {
      return true; // throw new IllegalStateException();
    }
    
    int count = length / BLOCK_SIZE + 1;
    
    if (_tailAddress <= _index + length + PAD + 2 * count) {
      return false;
    }

    _crc.update(buffer, offset, length);
    
    byte []headerBuffer = _headerBuffer;
    
    while (length > 0) {
      int sublen = Math.min(length, BLOCK_SIZE);
      
      BitsUtil.writeInt16(headerBuffer, 0, sublen);
      
      writeImpl(headerBuffer, 0, 2);
      writeImpl(buffer, offset, sublen);
      
      length -= sublen;
      offset += sublen;
    }
    
    return true;
  }
648466
protected void writeFull() {
        byte[] imageData = rawImage.getData();
        int numOfComponents = frameHeader.getNf();
        int[] pixes = new int[numOfComponents * DCTSIZE2];
        int blockIndex = 0;
        int startCoordinate = 0, scanlineStride = numOfComponents * rawImage.getWidth(), row = 0;

        x = 0;
        y = 0;

        for (int m = 0; m < MCUsPerColumn * MCUsPerRow; m++) {
            blockIndex = 0;

            // one MCU
            for (int v = 0; v < maxVSampleFactor; v++) {
                for (int h = 0; h < maxHSampleFactor; h++) {
                    row = y + 1;
                    startCoordinate = (y * rawImage.getWidth() + x) * numOfComponents;

                    // one block
                    for (int k = blockIndex * DCTSIZE2, i = 0; k < blockIndex * DCTSIZE2 + DCTSIZE2; k++) {
                        pixes[i++] = allMCUDatas[0][m][k];

                        if (numOfComponents > 1) {
                            pixes[i++] = allMCUDatas[1][m][k];
                            pixes[i++] = allMCUDatas[2][m][k];
                        }

                        if (numOfComponents > 3) {
                            pixes[i++] = allMCUDatas[3][m][k];
                        }

                        x++;

                        if (x % 8 == 0) {
                            y++;
                            x -= 8;
                        }
                    }

                    colorConvertor.convertBlock(pixes, 0, imageData, numOfComponents, startCoordinate, row,
                                                scanlineStride);

                    blockIndex++;

                    x += 8;
                    y -= 8;
                }

                x -= maxHSampleFactor * 8;
                y += 8;
            }

            x += maxHSampleFactor * 8;
            y -= maxVSampleFactor * 8;

            if (x >= rawImage.getWidth()) {
                x = 0;
                y += maxVSampleFactor * 8;
            }

        }
    }
1061605
public static void writeAll(GatheringByteChannel ch, ByteBuffer[] bbs, int offset, int length) throws IOException
    {
        long all = 0;
        for (int ii=0;ii<length;ii++)
        {
            all += bbs[offset+ii].remaining();
        }
        int count = 0;
        while (all > 0)
        {
            long rc = ch.write(bbs, offset, length);
            if (rc == 0)
            {
                count++;
            }
            else
            {
                all -= rc;
            }
            if (count > 100)
            {
                throw new IOException("Couldn't write all.");
            }
        }
    }
1261998
protected void writeBlock(Writer writer, String header, 
			String block) throws IOException {
		writeBlock(writer, null, header, block);
	}