type Reader struct {
io.Reader
Total int64
Written int64
}
func (r *Reader) Read(b []byte) (n int, err error) {
n, err = r.Reader.Read(b)
r.Written += int64(n)
fmt.Printf("\r进度 %.2f%%", float64(r.Written*10000/r.Total)/100)
return
}
for (int i = 1; i <= 100; i++) {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.print("\r我的进度是" + i + "%");
}