KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > util > ExposedByteArrayInputStream


1 package org.jgroups.util;
2
3 import java.io.ByteArrayInputStream JavaDoc;
4
5 /**
6  * @author Bela Ban
7  * @version $Id: ExposedByteArrayInputStream.java,v 1.1 2005/07/25 15:53:36 belaban Exp $
8  */

9 public class ExposedByteArrayInputStream extends ByteArrayInputStream JavaDoc {
10
11     
12     /**
13      * Creates a <code>ByteArrayInputStream</code>
14      * so that it uses <code>buf</code> as its
15      * buffer array.
16      * The buffer array is not copied.
17      * The initial value of <code>pos</code>
18      * is <code>0</code> and the initial value
19      * of <code>count</code> is the length of
20      * <code>buf</code>.
21      *
22      * @param buf the input buffer.
23      */

24     public ExposedByteArrayInputStream(byte[] buf) {
25         super(buf);
26     }
27
28     /**
29      * Creates <code>ByteArrayInputStream</code>
30      * that uses <code>buf</code> as its
31      * buffer array. The initial value of <code>pos</code>
32      * is <code>offset</code> and the initial value
33      * of <code>count</code> is the minimum of <code>offset+length</code>
34      * and <code>buf.length</code>.
35      * The buffer array is not copied. The buffer's mark is
36      * set to the specified offset.
37      *
38      * @param buf the input buffer.
39      * @param offset the offset in the buffer of the first byte to read.
40      * @param length the maximum number of bytes to read from the buffer.
41      */

42     public ExposedByteArrayInputStream(byte[] buf, int offset, int length) {
43         super(buf, offset, length);
44     }
45
46     public void setData(byte[] buf, int offset, int length) {
47         this.buf = buf;
48         this.pos = offset;
49         this.count = Math.min(offset + length, buf.length);
50         this.mark = offset;
51     }
52
53
54 }
55
Popular Tags