KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cz > cuni > sofa > lib > Impl > ByteArrayInputStream


1 /* $Id: ByteArrayInputStream.java,v 1.1.1.1 2003/02/11 16:19:40 bures Exp $ */
2
3 package cz.cuni.sofa.lib.Impl;
4 import java.io.IOException JavaDoc;
5
6 /** Implementation of InputStream over byte array.
7   */

8 public class ByteArrayInputStream extends cz.cuni.sofa.lib.InputStream {
9   private java.io.ObjectInputStream JavaDoc in;
10   private java.io.ByteArrayInputStream JavaDoc internal;
11
12   public ByteArrayInputStream(byte[] buff) throws IOException JavaDoc {
13     internal = new java.io.ByteArrayInputStream JavaDoc (buff);
14     in = new java.io.ObjectInputStream JavaDoc(internal);
15   }
16
17   public ByteArrayInputStream(String JavaDoc buff) throws IOException JavaDoc {
18     internal = new java.io.ByteArrayInputStream JavaDoc (buff.getBytes());
19     in = new java.io.ObjectInputStream JavaDoc(internal);
20   }
21
22   public int read() throws IOException JavaDoc {
23     return in.read();
24   }
25
26   public boolean read_boolean() throws IOException JavaDoc {
27     return in.readBoolean();
28   }
29
30   public char read_char() throws IOException JavaDoc {
31     return in.readChar();
32   }
33   
34   public char read_wchar() throws IOException JavaDoc {
35     return in.readChar();
36   }
37   public byte read_octet() throws IOException JavaDoc {
38     return in.readByte();
39   }
40   
41   public short read_short() throws IOException JavaDoc {
42     return in.readShort();
43   }
44   
45   public short read_ushort() throws IOException JavaDoc {
46     return in.readShort();
47   }
48   
49   public int read_long() throws IOException JavaDoc {
50     return in.readInt();
51   }
52   
53   public int read_ulong() throws IOException JavaDoc {
54     return in.readInt();
55   }
56   
57   public long read_longlong() throws IOException JavaDoc {
58     return in.readLong();
59   }
60   
61   public long read_ulonglong() throws IOException JavaDoc {
62     return in.readLong();
63   }
64   
65   public float read_float() throws IOException JavaDoc {
66     return in.readFloat();
67   }
68   
69   public double read_double() throws IOException JavaDoc {
70     return in.readDouble();
71   }
72   
73   public String JavaDoc read_string() throws IOException JavaDoc {
74     return in.readUTF();
75   }
76   
77   public String JavaDoc read_wstring() throws IOException JavaDoc {
78     return in.readUTF();
79   }
80
81   public void read_boolean_array(boolean[] value, int offset, int length) throws IOException JavaDoc {
82     for(int i=0; i<length; i++) {
83       value[offset+i] = in.readBoolean();
84     }
85   }
86
87   public void read_char_array(char[] value, int offset, int length) throws IOException JavaDoc {
88     for(int i=0; i<length; i++) {
89       value[offset+i] = in.readChar();
90     }
91   }
92   
93   public void read_wchar_array(char[] value, int offset, int length) throws IOException JavaDoc {
94     for(int i=0; i<length; i++) {
95       value[offset+i] = in.readChar();
96     }
97   }
98   
99   public void read_octet_array(byte[] value, int offset, int length) throws IOException JavaDoc {
100     for(int i=0; i<length; i++) {
101       value[offset+i] = in.readByte();
102     }
103   }
104   
105   public void read_short_array(short[] value, int offset, int length) throws IOException JavaDoc {
106     for(int i=0; i<length; i++) {
107       value[offset+i] = in.readShort();
108     }
109   }
110   public void read_ushort_array(short[] value, int offset, int length) throws IOException JavaDoc {
111     for(int i=0; i<length; i++) {
112       value[offset+i] = in.readShort();
113     }
114   }
115   
116   public void read_long_array(int[] value, int offset, int length) throws IOException JavaDoc {
117     for(int i=0; i<length; i++) {
118       value[offset+i] = in.readInt();
119     }
120   }
121   
122   public void read_ulong_array(int[] value, int offset, int length) throws IOException JavaDoc {
123     for(int i=0; i<length; i++) {
124       value[offset+i] = in.readInt();
125     }
126   }
127   
128   public void read_longlong_array(long[] value, int offset, int length) throws IOException JavaDoc {
129     for(int i=0; i<length; i++) {
130       value[offset+i] = in.readLong();
131     }
132   }
133   
134   public void read_ulonglong_array(long[] value, int offset, int length) throws IOException JavaDoc {
135     for(int i=0; i<length; i++) {
136       value[offset+i] = in.readLong();
137     }
138   }
139   
140   public void read_float_array(float[] value, int offset, int length) throws IOException JavaDoc {
141     for(int i=0; i<length; i++) {
142       value[offset+i] = in.readFloat();
143     }
144   }
145   
146   public void read_double_array(double[] value, int offset, int length) throws IOException JavaDoc {
147     for(int i=0; i<length; i++) {
148       value[offset+i] = in.readDouble();
149     }
150   }
151
152   public cz.cuni.sofa.lib.Object read_Object() throws IOException JavaDoc {
153     try {
154       return (cz.cuni.sofa.lib.Object) in.readObject();
155     } catch (ClassNotFoundException JavaDoc e) {
156       throw new IOException JavaDoc(e.getMessage());
157     }
158   }
159 }
160
Popular Tags