1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.monitor.jettyproxy;
14
15 import java.io.ByteArrayOutputStream;
16 import java.io.FilterInputStream;
17 import java.io.IOException;
18 import java.io.InputStream;
19
20 public class CaptureInputStream extends FilterInputStream
21 {
22 private final ByteArrayOutputStream capture = new ByteArrayOutputStream();
23
24 public CaptureInputStream( InputStream in )
25 {
26 super( in );
27 }
28
29 public int read() throws IOException
30 {
31 int i = super.read();
32 capture.write( i );
33 return i;
34 }
35
36 public int read( byte[] b ) throws IOException
37 {
38 int i = super.read( b );
39
40 return i;
41 }
42
43 public int read( byte[] b, int off, int len ) throws IOException
44 {
45 int i = super.read( b, off, len );
46 if( i > 0 ) {
47 capture.write( b, off, i );
48 }
49 return i;
50 }
51
52 public byte[] getCapturedData()
53 {
54 return capture.toByteArray();
55 }
56 }