Created
June 7, 2017 12:32
-
-
Save betrcode/ee2aa80da90f60467bff5617f6e15e03 to your computer and use it in GitHub Desktop.
Log progress of a InputStream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Timer logStreamProgress(CountingInputStream countingInputStream) { | |
final TimerTask timerTask = new TimerTask() { | |
int counter = 0; | |
@Override | |
public void run() { | |
LOGGER.info("Loaded {} in {} seconds", byteCountToDisplaySize(countingInputStream.getByteCount()), counter); | |
counter++; | |
} | |
}; | |
final Timer timer = new Timer(); | |
timer.schedule(timerTask, 0, Duration.ofSeconds(1).toMillis()); | |
return timer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment