1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.maven.wagon;
17
18 import java.io.File;
19 import java.io.FileNotFoundException;
20 import java.io.FileOutputStream;
21 import java.io.IOException;
22
23
24
25
26
27
28
29
30 class TransferProgressFileOutputStream extends FileOutputStream {
31
32 private TransferProgress progress;
33
34 public TransferProgressFileOutputStream(File file, TransferProgress progress) throws FileNotFoundException {
35 super(file);
36 this.progress = progress;
37 }
38
39 public void write(int b) throws IOException {
40 super.write(b);
41 progress.notify(new byte[]{(byte) b}, 1);
42 }
43
44 public void write(byte b[]) throws IOException {
45 super.write(b);
46 progress.notify(b, b.length);
47 }
48
49 public void write(byte b[], int off, int len) throws IOException {
50 super.write(b, off, len);
51 if (off == 0) {
52 progress.notify(b, len);
53 } else {
54 byte[] bytes = new byte[len];
55 System.arraycopy(b, off, bytes, 0, len);
56 progress.notify(bytes, len);
57 }
58 }
59 }