/** * @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 long getRemainingTime() { BytesProgressWatcher[] progressWatchers = new BytesProgressWatcher[1]; progressWatchers[0] = this; long bytesRemaining = bytesToTransfer - totalBytesInCurrentTransfer; double remainingSecs = bytesRemaining / calculateOverallBytesPerSecond(progressWatchers); return Math.round(remainingSecs); }
/** * @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 long getRemainingTime() { BytesProgressWatcher[] progressWatchers = new BytesProgressWatcher[1]; progressWatchers[0] = this; long bytesRemaining = bytesToTransfer - totalBytesInCurrentTransfer; double remainingSecs = bytesRemaining / calculateOverallBytesPerSecond(progressWatchers); 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); }
/** * @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); }