/** * Writes a {@link Container} header information to a {@link OutputStream}. * * @param major the CRAM version to assume * @param container the container holding the header to write * @param outputStream the stream to write to * @return the number of bytes written * @throws IOException as per java IO contract */ public static int writeContainerHeader(final int major, final Container container, final OutputStream outputStream) throws IOException { return new ContainerHeaderIO().writeContainerHeader(major, container, outputStream); }
public boolean readContainerHeader(final Container container, final InputStream inputStream) throws IOException { return readContainerHeader(2, container, inputStream); }
/** * Reads container header only from a {@link InputStream}. * * @param major the CRAM version to assume * @param inputStream the input stream to read from * @return a new {@link Container} object with container header values filled out but empty body (no slices and blocks). * @throws IOException as per java IO contract */ public static Container readContainerHeader(final int major, final InputStream inputStream) throws IOException { final Container container = new Container(); final ContainerHeaderIO containerHeaderIO = new ContainerHeaderIO(); if (!containerHeaderIO.readContainerHeader(major, container, inputStream)) { containerHeaderIO.readContainerHeader(container, new ByteArrayInputStream((major >= 3 ? CramIO.ZERO_F_EOF_MARKER : CramIO.ZERO_B_EOF_MARKER))); return container; } return container; }
/** * Reads container header only from a {@link InputStream}. * * @param major the CRAM version to assume * @param inputStream the input stream to read from * @return a new {@link Container} object with container header values filled out but empty body (no slices and blocks). */ public static Container readContainerHeader(final int major, final InputStream inputStream) { final Container container = new Container(); final ContainerHeaderIO containerHeaderIO = new ContainerHeaderIO(); if (!containerHeaderIO.readContainerHeader(major, container, inputStream)) { containerHeaderIO.readContainerHeader(container, new ByteArrayInputStream((major >= 3 ? CramIO.ZERO_F_EOF_MARKER : CramIO.ZERO_B_EOF_MARKER))); return container; } return container; }
/** * Writes a {@link Container} header information to a {@link OutputStream}. * * @param major the CRAM version to assume * @param container the container holding the header to write * @param outputStream the stream to write to * @return the number of bytes written */ public static int writeContainerHeader(final int major, final Container container, final OutputStream outputStream) { return new ContainerHeaderIO().writeContainerHeader(major, container, outputStream); }
public boolean readContainerHeader(final Container container, final InputStream inputStream) { return readContainerHeader(2, container, inputStream); }
container.containerByteSize = byteArrayOutputStream.size(); final int containerHeaderByteSize = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); try { outputStream.write(byteArrayOutputStream.toByteArray(), 0, byteArrayOutputStream.size()); calculateSliceOffsetsAndSizes(container); int length = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); try { outputStream.write(byteArrayOutputStream.toByteArray(), 0, byteArrayOutputStream.size());
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(); calculateSliceOffsetsAndSizes(container); int length = new ContainerHeaderIO().writeContainerHeader(version.major, container, outputStream); outputStream.write(byteArrayOutputStream.getBuffer(), 0, byteArrayOutputStream.size()); length += byteArrayOutputStream.size();