KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > util > ByteVectorOutputStream


1 package org.sapia.ubik.util;
2
3 import java.io.IOException JavaDoc;
4 import java.io.OutputStream JavaDoc;
5
6 /**
7  * This class implements an <code>OutputStream</code> over a ByteVector. The
8  * underlying vector can be reused by calling its <code>clear()</code> method
9  * (which will bring the vector back to its post-creation state).
10  * <p>
11  * <b>WARNING: THIS CLASS IS NOT THREAD-SAFE</b>.
12  *
13  * @author Yanick Duchesne
14  *
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2005 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
17  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
18  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
19  * </dl>
20  */

21 public class ByteVectorOutputStream extends OutputStream JavaDoc {
22   
23   private ByteVector _bytes;
24   
25   public ByteVectorOutputStream(ByteVector bytes){
26     _bytes = bytes;
27   }
28
29   /**
30    * @return the underlying <code>ByteVector</code> to which this instance writes.
31    */

32   public ByteVector getByteVector(){
33     return _bytes;
34   }
35   
36   /**
37    * @see java.io.OutputStream#close()
38    */

39   public void close() throws IOException JavaDoc {
40   }
41   
42   /**
43    * @see java.io.OutputStream#flush()
44    */

45   public void flush() throws IOException JavaDoc {
46   }
47   
48   /**
49    * @see java.io.OutputStream#write(byte[], int, int)
50    */

51   public void write(byte[] b, int off, int len) throws IOException JavaDoc {
52     _bytes.write(b, off, len);
53   }
54   
55   /**
56    * @see java.io.OutputStream#write(byte[])
57    */

58   public void write(byte[] b) throws IOException JavaDoc {
59     _bytes.write(b);
60   }
61   
62   /**
63    * @see java.io.OutputStream#write(int)
64    */

65   public void write(int b) throws IOException JavaDoc {
66     _bytes.write(b);
67   }
68 }
69
Popular Tags