KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > tasks > TaskInputStream


1 package com.sslexplorer.tasks;
2
3 import java.io.FilterInputStream JavaDoc;
4 import java.io.IOException JavaDoc;
5 import java.io.InputStream JavaDoc;
6
7
8 public class TaskInputStream extends FilterInputStream JavaDoc {
9
10     private TaskProgressBar bar;
11
12     public TaskInputStream(TaskProgressBar bar, InputStream JavaDoc 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 JavaDoc {
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 JavaDoc {
29         int x = in.read();
30         bar.setValue(bar.getValue() + 1);
31         return x;
32     }
33
34 }
35
Popular Tags