Package dijjer.io.download

Examples of dijjer.io.download.Download


    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();
      }
      StringBuffer rd = new StringBuffer(200);
      rd.append("<tr>");
      rd.append("<td>"
          + _reqUrl.toString().substring(
              _reqUrl.toString().lastIndexOf("/") + 1,
              _reqUrl.toString().length()) + "</td>");
      rd.append("<td>" + (_length / 1024) + "</td>");
      rd
          .append("<td>"
              + ((int) ((1000f * (float) dl.getDownloaded()) / (1024f * (float) totalTime)))
              + "</td>");
      String md5Colour;
      if (correctMD5 == null) {
        md5Colour = "#000000";
      } else {
        if (correctMD5.equalsIgnoreCase(actualMD5)) {
          md5Colour = "#00FF00";
        } else {
          md5Colour = "#FF0000";
          Logger.warning("File " + _reqUrl + " failed MD5Sum check!");
        }
      }
      rd.append("<td><font color=\"" + md5Colour + "\">" + actualMD5
          + "</font></td>");
      rd.append("<td>"
          + Math.min(100, (dl.getBytesFromCache() * 100)
              / dl.getDownloaded()) + "</td>");
      rd.append("</tr>");
      recentDownloads.addFirst(rd.toString());
    }
  }
View Full Code Here


    } else {
      StringBuffer sb = new StringBuffer();
      sb
          .append("<table border=\"1\"><tr><td><b>File</b></td><td><b>Length</b></td><td><b>% Downloaded</b></td><td><b>% Sent to Client</b></td><td><b>% from cache</b></td></tr>");
      for (Iterator i = jobs.iterator(); i.hasNext();) {
        Download dl = (Download) i.next();
        sb.append("<tr><td>" + dl.getFileName() + "</td>");
        sb.append("<td>" + dl.getLength() + "</td>");
        sb.append("<td>" + Math.min(100, (dl.getDownloaded() * 100) / dl.getLength()) + "</td>");
        sb.append("<td>" + ((dl.getSent() * 100) / dl.getLength()) + "</td>");
        if (dl.getSent() > 0) {
          sb.append("<td>" + Math.min(100, (dl.getBytesFromCache() * 100) / dl.getDownloaded()) + "</td>");
        } else {
          sb.append("<td>0</td>");
        }
        sb.append("</tr>");
      }
View Full Code Here

TOP

Related Classes of dijjer.io.download.Download

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.