Source:
<code>public static int writeContainer(final Version version, final Container container, final OutputStream outputStream) throws IOException { { if (container.blocks != null && container.blocks.length > 0) { final Block firstBlock = container.blocks[0]; final boolean isFileHeaderContainer = firstBlock.getContentType() == BlockContentType.FILE_HEADER; if (isFileHeaderContainer) { final ExposedByteArrayOutputStream byteArrayOutputStream = new ExposedByteArrayOutputStream(); firstBlock.write(version.major, byteArrayOutputStream); container.containerByteSize = byteArrayOutputStream.size(); final int containerHeaderByteSize = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); outputStream.write(byteArrayOutputStream.getBuffer(), 0, byteArrayOutputStream.size()); return containerHeaderByteSize + byteArrayOutputStream.size(); } } } final ExposedByteArrayOutputStream byteArrayOutputStream = new ExposedByteArrayOutputStream(); <START> final Block block = Block.uncompressedCompressionHeaderBlock(container.header.toByteArray()); <END> block.write(version.major, byteArrayOutputStream); container.blockCount = 1; final List<Integer> landmarks = new ArrayList<Integer>(); for (int i = 0; i < container.slices.length; i++) { final Slice slice = container.slices[i]; landmarks.add(byteArrayOutputStream.size()); SliceIO.write(version.major, slice, byteArrayOutputStream); container.blockCount++; container.blockCount++; if (slice.embeddedRefBlock != null) container.blockCount++; container.blockCount += slice.external.size(); } container.landmarks = new int[landmarks.size()]; for (int i = 0; i < container.landmarks.length; i++) container.landmarks[i] = landmarks.get(i); container.containerByteSize = byteArrayOutputStream.size(); calculateSliceOffsetsAndSizes(container); int length = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); outputStream.write(byteArrayOutputStream.getBuffer(), 0, byteArrayOutputStream.size()); length += byteArrayOutputStream.size(); log.debug("CONTAINER WRITTEN: " + container.toString()); return length; }</code><technical_language>ContainerHeader a toBlock</technical_language>

Target:
public static int writeContainer(final Version version, final Container container, final OutputStream outputStream) throws IOException { { if (container.blocks != null && container.blocks.length > 0) { final Block firstBlock = container.blocks[0]; final boolean isFileHeaderContainer = firstBlock.getContentType() == BlockContentType.FILE_HEADER; if (isFileHeaderContainer) { final ExposedByteArrayOutputStream byteArrayOutputStream = new ExposedByteArrayOutputStream(); firstBlock.write(version.major, byteArrayOutputStream); container.containerByteSize = byteArrayOutputStream.size(); final int containerHeaderByteSize = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); outputStream.write(byteArrayOutputStream.getBuffer(), 0, byteArrayOutputStream.size()); return containerHeaderByteSize + byteArrayOutputStream.size(); } } } final ExposedByteArrayOutputStream byteArrayOutputStream = new ExposedByteArrayOutputStream(); container.header.write(version, byteArrayOutputStream); container.blockCount = 1; final List<Integer> landmarks = new ArrayList<>(); for (int i = 0; i < container.slices.length; i++) { final Slice slice = container.slices[i]; landmarks.add(byteArrayOutputStream.size()); SliceIO.write(version.major, slice, byteArrayOutputStream); container.blockCount++; container.blockCount++; if (slice.embeddedRefBlock != null) container.blockCount++; container.blockCount += slice.external.size(); } container.landmarks = new int[landmarks.size()]; for (int i = 0; i < container.landmarks.length; i++) container.landmarks[i] = landmarks.get(i); container.containerByteSize = byteArrayOutputStream.size(); calculateSliceOffsetsAndSizes(container); int length = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); outputStream.write(byteArrayOutputStream.getBuffer(), 0, byteArrayOutputStream.size()); length += byteArrayOutputStream.size(); log.debug("CONTAINER WRITTEN: " + container.toString()); return length; }