MCPcopy Create free account
hub / github.com/ReadyTalk/avian / DataInputStream

Class DataInputStream

classpath/java/io/DataInputStream.java:13–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11package java.io;
12
13public class DataInputStream extends InputStream implements DataInput {
14 private InputStream in;
15
16 public DataInputStream(InputStream in) {
17 this.in = in;
18 }
19
20 public void close() throws IOException {
21 in.close();
22 }
23
24 public int read(byte[] buffer) throws IOException {
25 return in.read(buffer);
26 }
27
28 public int read(byte[] buffer, int offset, int length) throws IOException {
29 return in.read(buffer, offset, length);
30 }
31
32 public void readFully(byte[] b) throws IOException {
33 readFully(b, 0, b.length);
34 }
35
36 public void readFully(byte[] b, int offset, int length) throws IOException {
37 while (length > 0) {
38 int count = read(b, offset, length);
39 if (count < 0) {
40 throw new EOFException("Reached EOF " + length + " bytes too early");
41 }
42 offset += count;
43 length -= count;
44 }
45 }
46
47 public int read() throws IOException {
48 return in.read();
49 }
50
51 private int read0() throws IOException {
52 int b = in.read();
53 if (b < 0) {
54 throw new EOFException();
55 }
56 return b;
57 }
58
59 public boolean readBoolean() throws IOException {
60 return read0() != 0;
61 }
62
63 public byte readByte() throws IOException {
64 return (byte)read0();
65 }
66
67 public short readShort() throws IOException {
68 return (short)((read0() << 8) | read0());
69 }
70

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected