4 public class ProgressInputStream extends FilterInputStream {
10 public ProgressInputStream(String title, InputStream o) { this(title, o, -1); }
12 public ProgressInputStream(String title, InputStream o, int size) {
18 public int read() throws IOException {
19 int ret = super.read();
20 if (ret != -1) bytes++;
24 public int read(byte[] b, int off, int len) throws IOException {
25 int ret = super.read(b, off, len);
26 if (ret != -1) bytes += ret;
31 private void update() {
32 System.out.print("\r \r");
33 System.out.print(title);
35 int frac = (100 * bytes) / size;
36 String fracs = frac+"";
37 while(fracs.length()<3) fracs = " "+fracs;
38 System.out.print(" ");
39 System.out.print("\033[32m");
40 System.out.print(fracs+"%");
41 System.out.print("\033[0m");
43 System.out.print(" ");
44 System.out.print(bytes);
45 System.out.print(" bytes ");
48 public void close() throws IOException {