public static long checksumRandomAccessFile(Path filename) throws IOException {
    try (RandomAccessFile file = new RandomAccessFile(filename.toFile(), "r")) {
      long length = file.length();
      CRC32 crc = new CRC32();

      for (long p = 0; p < length; p++) {
        file.seek(p);
        int c = file.readByte();
        crc.update(c);
      }
      return crc.getValue();
    }
  }
Beispiel #2
0
  @Override
  public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
    if (_pathMatcher.matches(file.getFileName())) storeFile(file.toFile());

    return super.visitFile(file, attrs);
  }