Java Byte Stream DataInputStream/DataOutputStream
DataInputStream Constructor
| Constructor | Description |
|---|---|
| DataInputStream(InputStream in) | Creates a DataInputStream with inputStream as an argument. |
DataInputStream Methods
| Method | Description |
|---|---|
| boolean readBoolean() throws IOException | Returns a boolean read from the Stream. |
| byte readByte() throws IOException | Returns a byte read from the Stream. |
| char readChar() throws IOException | Returns a char read from the Stream. |
| double readDouble() throws IOException | Returns a double from the Stream. |
| float readFloat() throws IOException | Returns a float from the Stream. |
| long readLong() throws IOException | Returns a long from the Stream. |
| short readShort() throws IOException | Returns a short from the Stream. |
| int readInt() throws IOException | Returns an int from the Stream. |
| void readFully(byte[] buf) throws IOException | Reads bytes from the Stream up to the size of buf and stores them in buf[]. |
| void readFully(byte[] buf, int off, int len) throws IOException | Reads len bytes from the Stream and stores them at the off position of buf. |
| String readUTF() throws IOException | Gets a UTF-encoded value and returns it as a string. |
| static String readUTF(DataInput in) throws IOException | Gets the modified UTF-encoded value of DataInput and returns it as a string. |
| int skipBytes(int n) throws IOException | Skips n bytes. |
DataOutputStream Constructor
| Constructor | Description |
|---|---|
| DataOutputStream(OutputStream out) | Creates a DataOutputStream with outputStream as an argument. |
DataOutputStream Methods
| Method | Description |
|---|---|
| void flush() throws IOException | Outputs and clears the buffer. |
| int size() | Returns the number of bytes output to the Stream. |
| void write(int i) throws IOException | Outputs the 1 byte held by the int value i. |
| void write(byte buf[], int index, int size) throws IOException | Outputs size bytes from the index position of the byte array buf. |
| void writeBoolean(boolean b) throws IOException | Outputs a boolean as a 1-byte value. |
| void writeByte(int i) throws IOException | Outputs an int as a 4-byte value, high-order byte first. |
| void writeBytes(String s) throws IOException | Outputs the string in byte order. |
| void writeChar(int i) throws IOException | Outputs a char as a 2-byte value, high-order byte first. |
| void writeChars(String s) throws IOException | Outputs a String as char values. |
| void writeDouble(double d) throws IOException | Converts the double to a long using Double.doubleToBits(), then outputs the long value as 8 bytes, high-order byte first. |
| void writeFloat(float f) throws IOException | Converts the float using Float.floatToBits(), then outputs the int value as 4 bytes, high-order byte first. |
| void writeInt(int i) throws IOException | Outputs the high-order byte of the int first. |
| void writeLong(long l) throws IOException | Outputs the long argument value. |
| void writeShort(short s) throws IOException | Outputs the short argument value. |
| void writeUTF(String s) throws IOException | Outputs the string using UTF-8 encoding. |