1 package fr.in2p3.jsaga.impl.file.copy;
2
3 import java.io.IOException;
4 import java.io.OutputStream;
5
6 import org.ogf.saga.file.FileOutputStream;
7
8
9
10
11
12
13
14
15
16
17 public class MonitoredOutputStream extends OutputStream {
18
19 private FileOutputStream out;
20 private AbstractCopyTask monitor;
21
22 public MonitoredOutputStream(FileOutputStream o, AbstractCopyTask a) {
23 this.out = o;
24 this.monitor = a;
25 }
26
27 @Override
28 public void write(int b) throws IOException {
29 out.write(b);
30 }
31
32 @Override
33 public void write(byte b[]) throws IOException {
34 this.out.write(b);
35 if (this.monitor != null)
36 this.monitor.increment(b.length);
37 }
38
39 @Override
40 public void write(byte b[], int off, int len) throws IOException {
41 this.out.write(b, off, len);
42 if (this.monitor != null)
43 this.monitor.increment(len);
44 }
45 }