Package dijjer.util

Examples of dijjer.util.MD5OutputStream


*/
public class MD5OutputStreamTest extends TestCase {

  public void testMain() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    MD5OutputStream mos = new MD5OutputStream(baos);
    byte[] toWrite = ("this is a test of md5sum").getBytes();
    mos.write(toWrite);
    mos.close();
    assertEquals(mos.getMD5Sum(), "3aa729600069942b5d4529e1614749b4");
    byte[] written = baos.toByteArray();
    assertEquals(toWrite.length, written.length);
    for (int x=0; x<toWrite.length; x++) {
      assertEquals(toWrite[x], written[x]);
    }
View Full Code Here


  protected long getContentLength() {
    return _length;
  }

  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,
        endBlock, tos);
    long startTime = System.currentTimeMillis();
    dl.start();
    long totalTime = System.currentTimeMillis() - startTime;
    String actualMD5 = out.getMD5Sum();
    String correctMD5 = downloadMd5();
    synchronized (recentDownloads) {
      while (recentDownloads.size() >= MAX_RECENT_DOWNLOADS) {
        recentDownloads.removeLast();
      }
View Full Code Here

TOP

Related Classes of dijjer.util.MD5OutputStream

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.