Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/anotherbigidea/io/OutputStreamWrapper.java


1   package com.anotherbigidea.io;
2   
3   import java.io.IOException;
4   import java.io.OutputStream;
5   
6   /**
7    * Base class for output stream wrappers
8    * 
9    * @author nick
10   */
11  public abstract class OutputStreamWrapper extends CountingOutputStream {
12    
13    private OutputStream mOut;
14  
15    protected OutputStreamWrapper( OutputStream out ) {
16      mOut = out;
17    }
18    
19    /**
20     * Change the wrapped output stream
21     */
22    public void setOutputStream( OutputStream out ) {
23      mOut = out;
24    }    
25  
26    /**
27     * Get the wrapped output stream
28     */
29    protected OutputStream getOutputStream() {
30      return mOut;
31    }
32  
33    /**
34     * @see java.io.OutputStream#write(int)
35     */
36    public void write( int b ) throws IOException {
37      mOut.write( b );
38      mCount++;
39    }
40  
41    /**
42     * @see java.io.OutputStream#close()
43     */
44    public void close() throws IOException {
45      mOut.close();
46    }
47  
48    /**
49     * @see java.io.OutputStream#flush()
50     */
51    public void flush() throws IOException {
52      mOut.flush();
53    }
54  
55    /**
56     * @see java.io.OutputStream#write(byte[], int, int)
57     */
58    public void write( byte[] b, int start, int len ) throws IOException {
59      mOut.write( b, start, len );
60      mCount += len;
61    }
62  
63    /**
64     * @see java.io.OutputStream#write(byte[])
65     */
66    public void write( byte[] b ) throws IOException {
67      mOut.write( b );
68      mCount += b.length;
69    }
70  }