Java DataInputStream.readByte()
Syntax
DataInputStream.readByte() has the following syntax.
public final byte readByte() throws IOException
Example
In the following code shows how to use DataInputStream.readByte() method.
//w ww .j av a 2 s .c o m
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
public class Main {
public static void main(String[] args) throws IOException {
byte[] buf = { 1, 2, 3, 4, 5 };
InputStream is = new ByteArrayInputStream(buf);
DataInputStream dis = new DataInputStream(is);
while (dis.available() > 0) {
byte b = dis.readByte();
System.out.print(b);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »