/** * @return * the expected total of bytes that will be transferred by the watched threads. * @throws IllegalStateException * if the bytes transferred information is not available - check this availability * with the {@link #isBytesTransferredInfoAvailable()} method. */ public long getBytesTotal() throws IllegalStateException { if (!isBytesTransferredInfoAvailable()) { throw new IllegalStateException("Bytes Transferred Info is not available in this object"); } return BytesProgressWatcher.sumBytesToTransfer(progressWatchers); }
/** * @return * the expected total of bytes that will be transferred by the watched threads. * @throws IllegalStateException * if the bytes transferred information is not available - check this availability * with the {@link #isBytesTransferredInfoAvailable()} method. */ public long getBytesTotal() throws IllegalStateException { if (!isBytesTransferredInfoAvailable()) { throw new IllegalStateException("Bytes Transferred Info is not available in this object"); } return BytesProgressWatcher.sumBytesToTransfer(progressWatchers); }
/** * @param progressWatchers * all the watchers involved in the same byte transfer operation. * @return * an estimate of the time (in seconds) it will take for the transfer to completed, based * on the number of bytes remaining to transfer and the overall bytes/second rate. */ public static long calculateRemainingTime(BytesProgressWatcher[] progressWatchers) { long bytesRemaining = sumBytesToTransfer(progressWatchers) - sumBytesTransferred(progressWatchers); double bytesPerSecond = calculateOverallBytesPerSecond(progressWatchers); if (Math.abs(bytesPerSecond) < 0.001d) { // No transfer has occurred yet. return 0; } double remainingSecs = bytesRemaining / bytesPerSecond; return Math.round(remainingSecs); }
/** * @param progressWatchers * all the watchers involved in the same byte transfer operation. * @return * an estimate of the time (in seconds) it will take for the transfer to completed, based * on the number of bytes remaining to transfer and the overall bytes/second rate. */ public static long calculateRemainingTime(BytesProgressWatcher[] progressWatchers) { long bytesRemaining = sumBytesToTransfer(progressWatchers) - sumBytesTransferred(progressWatchers); double bytesPerSecond = calculateOverallBytesPerSecond(progressWatchers); if (Math.abs(bytesPerSecond) < 0.001d) { // No transfer has occurred yet. return 0; } double remainingSecs = bytesRemaining / bytesPerSecond; return Math.round(remainingSecs); }