Closed NikR-IV closed 2 years ago
the trueSize
here should be 722 * 1048576
since you are setting the unit to be MiB = 1048576
.
It still doesn't work for me :(
long trueSize = 757071872;
ProgressBarBuilder pbb = new ProgressBarBuilder().setTaskName("download").setInitialMax(trueSize).setUnit("MiB", 1048576);
try(InputStream is = ProgressBar.wrap(response.bodyStream(),pbb)){
Files.copy(is, Paths.get(downloadPath));
} catch (IOException e) {
e.printStackTrace();
}
I change the code in public static InputStream wrap(InputStream is, ProgressBarBuilder pbb)
from if (size != -1 && pbb.initialMaxIsSet())
to if (size != -1 && !pbb.initialMaxIsSet())
, and it works.
I change the code in public static InputStream wrap(InputStream is, ProgressBarBuilder pbb)
from if (size != -1 && pbb.initialMaxIsSet())
to if (size != -1 && !pbb.initialMaxIsSet())
, and it works.
Thanks @NikR-IV ! Great catch!
Hello! This library work all fine for me, but when I tried to visualize the process of reading from a HTTP response bodystream, progress bar's max size kept increasing with current size from 0, but not set to the value used in .setInitialMax() here's my code:
and console output's just like this: download 100% │████████████████████████████│ 0/0MiB (0:00:00 / 0:00:00) download 100% │████████████████████████████│ 1/1MiB (0:00:03 / 0:00:00) download 100% │████████████████████████████│ 2/2MiB (0:00:05 / 0:00:00) download 100% │████████████████████████████│ 3/3MiB (0:00:08 / 0:00:00) ...