Skip to content

Instantly share code, notes, and snippets.

@betrcode
Created June 7, 2017 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betrcode/ee2aa80da90f60467bff5617f6e15e03 to your computer and use it in GitHub Desktop.
Save betrcode/ee2aa80da90f60467bff5617f6e15e03 to your computer and use it in GitHub Desktop.
Log progress of a InputStream
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