Online Java Compiler By
JavaTpoint.com
import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; public class ObjectInputStreamreadByteExample1 { public static void main(String[] args) throws IOException { InputStream instream = null; DataInputStream datainsstream = null; byte[] buff = {65, 0, 0, 68, 69}; try { // create new byte array input stream instream = new ByteArrayInputStream(buff); // create data input stream datainsstream = new DataInputStream(instream); // readBoolean till the data available to read while( datainsstream.available() >0) { // read one single byte byte bt = datainsstream.readByte(); // print the byte System.out.print(bt+" "); } } catch(Exception e) { // if any I/O error occurs e.printStackTrace(); } } }
Output