/** * Resets the number of bytes that have been processed in the current file. */ public void resetCurrentFileByteCounter() { currentFileByteCounter.reset(); }
/** * Increases the byte counter by the number of bytes contained in the specified counter (as returned by its * {@link #getByteCount()} method) and resets its byte counter after (if specified). * * @param counter the Bytecounter to add to this one, and reset after (if specified). * @param resetAfter if true, the specified counter will be reset after its byte count has been added to this ByteCounter */ public synchronized void add(ByteCounter counter, boolean resetAfter) { // Hold a lock on the provided counter to make sure that it is not modified or accessed // while this operation is carried out synchronized(counter) { add(counter.getByteCount()); if(resetAfter) counter.reset(); } }
private String calculateChecksum(AbstractFile file) throws IOException, NoSuchAlgorithmException { currentFileByteCounter.reset(); InputStream in = setCurrentInputStream(file.getInputStream()); try { return AbstractFile.calculateChecksum(in, MessageDigest.getInstance(CHECKSUM_VERIFICATION_ALGORITHM)); } finally { closeCurrentInputStream(); } }