View Javadoc
1   package org.codehaus.plexus.components.io.resources;
2   
3   import java.io.IOException;
4   import java.io.InputStream;
5   
6   /**
7    * @author Kristian Rosenvold
8    */
9   public class ClosingInputStream
10      extends InputStream
11  {
12      private final InputStream target;
13  
14      private final InputStream other;
15  
16      public ClosingInputStream( InputStream target, InputStream other )
17      {
18          this.target = target;
19          this.other = other;
20      }
21  
22      @Override
23      public int read()
24          throws IOException
25      {
26          return target.read();
27      }
28  
29      @Override
30      public int read( byte[] b )
31          throws IOException
32      {
33          return target.read( b );
34      }
35  
36      @Override
37      public int read( byte[] b, int off, int len )
38          throws IOException
39      {
40          return target.read( b, off, len );
41      }
42  
43      @Override
44      public long skip( long n )
45          throws IOException
46      {
47          return target.skip( n );
48      }
49  
50      @Override
51      public int available()
52          throws IOException
53      {
54          return target.available();
55      }
56  
57      @Override
58      public void close()
59          throws IOException
60      {
61          other.close();
62          target.close();
63      }
64  
65      @Override
66      public void mark( int readlimit )
67      {
68          target.mark( readlimit );
69      }
70  
71      @Override
72      public void reset()
73          throws IOException
74      {
75          target.reset();
76      }
77  
78      @Override
79      public boolean markSupported()
80      {
81          return target.markSupported();
82      }
83  }