Exemplo n.º 1
0
  public static void main(String[] args) throws IOException {
    System.out.println("Input Stream:");
    long start = System.currentTimeMillis();
    Path filename = Paths.get(args[0]);
    long crcValue = checksumInputStream(filename);
    long end = System.currentTimeMillis();
    System.out.println(Long.toHexString(crcValue));
    System.out.println((end - start) + " milliseconds");

    System.out.println("Buffered Input Stream:");
    start = System.currentTimeMillis();
    crcValue = checksumBufferedInputStream(filename);
    end = System.currentTimeMillis();
    System.out.println(Long.toHexString(crcValue));
    System.out.println((end - start) + " milliseconds");

    System.out.println("Random Access File:");
    start = System.currentTimeMillis();
    crcValue = checksumRandomAccessFile(filename);
    end = System.currentTimeMillis();
    System.out.println(Long.toHexString(crcValue));
    System.out.println((end - start) + " milliseconds");

    System.out.println("Mapped File:");
    start = System.currentTimeMillis();
    crcValue = checksumMappedFile(filename);
    end = System.currentTimeMillis();
    System.out.println(Long.toHexString(crcValue));
    System.out.println((end - start) + " milliseconds");
  }
Exemplo n.º 2
0
 public static String calculateCrc32(String source) {
   CRC32 crc32 = new CRC32();
   Adler32 adler32 = new Adler32();
   adler32.update(source.getBytes());
   System.out.println(adler32.getValue());
   crc32.update(source.getBytes());
   StringBuilder builder = new StringBuilder(8);
   System.out.println(crc32.getValue());
   System.out.println(Long.toHexString(crc32.getValue()));
   builder.append(Long.toHexString(crc32.getValue()));
   if (builder.length() < 8) {
     builder.append(CHAR_TEMPLATE, 0, 8 - builder.length());
   }
   System.out.println(builder.toString());
   return builder.toString();
 }
Exemplo n.º 3
0
 /** Prints entry information. */
 void printEntry(ZipEntry e) throws IOException {
   if (vflag) {
     StringBuilder sb = new StringBuilder();
     String s = Long.toString(e.getSize());
     for (int i = 6 - s.length(); i > 0; --i) {
       sb.append(' ');
     }
     sb.append(s).append(' ').append(new Date(e.getTime()).toString());
     sb.append(' ').append(e.getName());
     output(sb.toString());
   } else {
     output(e.getName());
   }
 }
Exemplo n.º 4
0
 /** Sets the total length of the file being imported. */
 public void setLength(long length) {
   props.put(KEY_LENGTH, Long.toString(length));
 }
Exemplo n.º 5
0
 @Override
 public int compare(VisorLogFile f1, VisorLogFile f2) {
   return Long.compare(f2.lastModified(), f1.lastModified());
 }
Exemplo n.º 6
0
 @Override
 public int compare(Event o1, Event o2) {
   return Long.compare(o1.localOrder(), o2.localOrder());
 }