Package uk.ac.ebi.ena.sra.cram.io

Examples of uk.ac.ebi.ena.sra.cram.io.ExposedByteArrayOutputStream


  public Definition getDefinition() {
    return definition;
  }

  public int writeBlock(Block block, OutputStream os) throws IOException {
    ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream();
    block.bytes = writeData(baos, block.data, block.method);
    block.dataBytes = block.data.length;

    ExposedByteArrayOutputStream baos2 = new ExposedByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos2);
    dos.writeByte(block.contentType);
    dos.writeShort(block.contentId);
    dos.writeByte(block.method);
    dos.writeInt(block.bytes);
    dos.writeInt(block.dataBytes);

    int len = 1 + 2 + 1 + 4 + 4;
    dos.write(baos.getBuffer(), 0, baos.size());
    len += block.bytes;

    dos.close();

    os.write(baos2.getBuffer(), 0, baos2.size());

    // System.out.printf("block written: %d, %d, %d, %d, %d, %s\n",
    // block.contentType, block.contentId, block.method, block.bytes,
    // block.dataBytes, flanksToHex(block.data, 10));
    return len;
View Full Code Here


    }
    return c;
  }

  public int writeContainer(Container c, OutputStream os) throws IOException {
    ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);

    dos.writeInt(c.blocks.length);
    dos.writeInt(c.containers.length);

    for (Block block : c.blocks)
      writeBlock((Block) block, dos);

    for (Container container : c.containers)
      writeContainer(container, dos);

    dos.flush();

    dos = new DataOutputStream(os);

    int len = 0;
    dos.writeLong(c.contentId);
    len += 8;
    dos.writeInt(baos.size());
    len += 4;

    dos.write(baos.getBuffer(), 0, baos.size());
    dos.flush();
    len += baos.size();

    baos.reset();

    return len;
  }
View Full Code Here

    limitedInputStream.skipToEnd();
    return unpackedData;
  }

  private int writeData(OutputStream os, byte[] data, byte method) throws IOException {
    ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream();
    OutputStream wrappedOS = wrapOutputStream(baos, method);
    wrappedOS.write(data);
    wrappedOS.close();
    os.write(baos.getBuffer(), 0, baos.size());

    return baos.size();
  }
View Full Code Here

TOP

Related Classes of uk.ac.ebi.ena.sra.cram.io.ExposedByteArrayOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.