Package dijjer.util

Examples of dijjer.util.TruncatingOutputStream


* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class TruncatingOutputStreamTest extends TestCase {
  public void testTOS() throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    TruncatingOutputStream tos = new TruncatingOutputStream(bos, 2, 8);
    tos.write(new byte[] {55, 0, 1, 2, 3, 4, 55, 55, 55}, 1, 5);
    tos.write(new byte[] {55, 5, 6, 7, 8, 9, 10, 11}, 1, 7);
    byte[] ba = bos.toByteArray();
    byte[] correct = new byte[] {2, 3, 4, 5, 6, 7, 8, 9};
    boolean same = ba.length == correct.length;
    for (int x=0; x<ba.length; x++) {
      System.out.print(" "+ba[x]+":"+correct[x]);
View Full Code Here


  protected void writeTo(OutputStream o) throws IOException {
    MD5OutputStream out = new MD5OutputStream(o);
    out.write(_initialSniffBytes);
    int startBlock = (int) (_rangeStart / Store.DATA_BLOCK_SIZE);
    int endBlock = (int) (_rangeEnd / Store.DATA_BLOCK_SIZE);
    OutputStream tos = new TruncatingOutputStream(out,
        DownloadHandler.INITIAL_SNIFF_BYTES
            + (_rangeStart % Store.DATA_BLOCK_SIZE),
        (_rangeEnd - _rangeStart) + 1
            - DownloadHandler.INITIAL_SNIFF_BYTES);
    Download dl = new Download(_reqUrl, _length, _lastModified, startBlock,
View Full Code Here

TOP

Related Classes of dijjer.util.TruncatingOutputStream

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.