1 package com.sslexplorer.tasks; 2 3 import java.io.FilterInputStream ; 4 import java.io.IOException ; 5 import java.io.InputStream ; 6 7 8 public class TaskInputStream extends FilterInputStream { 9 10 private TaskProgressBar bar; 11 12 public TaskInputStream(TaskProgressBar bar, InputStream in) { 13 super(in); 14 this.in = in; 15 this.bar = bar; 16 } 17 18 public TaskProgressBar getProgressBar() { 19 return bar; 20 } 21 22 public int read(byte b[], int off, int len) throws IOException { 23 int x = in.read(b, off, len); 24 bar.setValue(bar.getValue() + x); 25 return x; 26 } 27 28 public int read() throws IOException { 29 int x = in.read(); 30 bar.setValue(bar.getValue() + 1); 31 return x; 32 } 33 34 } 35 | Popular Tags |