Package de.scrum_master.galileo.tool

Source Code of de.scrum_master.galileo.tool.DownloadChecker

package de.scrum_master.galileo.tool;

import java.math.BigInteger;
import java.net.URL;

import de.scrum_master.galileo.Book;
import de.scrum_master.util.FileDownloader;

public class DownloadChecker {
  /**
   * Checks <b>all</b> Galileo Openbooks for availability by downloading them and verifying their MD5 checksums.
   *
   * <b>Attention:</b> This is a long-running operation (~14 minutes on my old PC using 16 Mbit/s downstream DSL)
   * which as of 2013-03-10 downloads at least 1.1 Gb of data!
   */
  public static void main(String[] args) {
    long startTime = System.currentTimeMillis();
    Book.readConfig(true);
    System.out.println("\nChecking book downloads and MD5 checksums:");
    for (String bookID : Book.books.keySet()) {
      Book book = Book.books.get(bookID);
      System.out.print("  " + bookID + " ... ");
      try {
        new FileDownloader(new URL(book.downloadArchive), null, new BigInteger(book.archiveMD5, 16)).download();
        System.out.println("OK");
      } catch (Exception e) {
        System.out.println("failed");
        e.printStackTrace();
      }
    }
    System.out.println("\nExecution time: " + (System.currentTimeMillis() - startTime) / 1000.0 + " s");
  }
}
TOP

Related Classes of de.scrum_master.galileo.tool.DownloadChecker

TOP
Copyright © 2018 www.massapi.com. 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.