MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / DataInputStream

Class DataInputStream

vm/JavaAPI/src/java/io/DataInputStream.java:29–280  ·  view source on GitHub ↗

A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream. Since: JDK1.0, CLDC 1.0 See Also:DataOutputStream

Source from the content-addressed store, hash-verified

27 * Since: JDK1.0, CLDC 1.0 See Also:DataOutputStream
28 */
29public class DataInputStream extends FilterInputStream implements java.io.DataInput{
30 private final byte[] scratch = new byte[8];
31
32 /**
33 * Creates a DataInputStream and saves its argument, the input stream in, for later use.
34 * in - the input stream.
35 */
36 public DataInputStream(java.io.InputStream in){
37 super(in);
38 }
39
40 /**
41 * See the general contract of the readBoolean method of DataInput.
42 * Bytes for this operation are read from the contained input stream.
43 */
44 public final boolean readBoolean() throws java.io.IOException{
45 int temp = in.read();
46 if (temp < 0) {
47 throw new EOFException();
48 }
49 return temp != 0;
50 }
51
52 /**
53 * See the general contract of the readByte method of DataInput.
54 * Bytes for this operation are read from the contained input stream.
55 */
56 public final byte readByte() throws java.io.IOException{
57 int temp = in.read();
58 if (temp < 0) {
59 throw new EOFException();
60 }
61 return (byte) temp;
62 }
63
64 /**
65 * See the general contract of the readChar method of DataInput.
66 * Bytes for this operation are read from the contained input stream.
67 */
68 public final char readChar() throws java.io.IOException{
69 return (char) readShort();
70 }
71
72 /**
73 * See the general contract of the readDouble method of DataInput.
74 * Bytes for this operation are read from the contained input stream.
75 */
76 public final double readDouble() throws java.io.IOException{
77 return Double.longBitsToDouble(readLong());
78 }
79
80 /**
81 * See the general contract of the readFloat method of DataInput.
82 * Bytes for this operation are read from the contained input stream.
83 */
84 public final float readFloat() throws java.io.IOException{
85 return Float.intBitsToFloat(readInt());
86 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected