Java IO Tutorial - Java ByteArrayInputStream(byte[] buf) Constructor








Syntax

ByteArrayInputStream(byte[] buf) constructor from ByteArrayInputStream has the following syntax.

public ByteArrayInputStream(byte[] buf)

Example

In the following code shows how to use ByteArrayInputStream.ByteArrayInputStream(byte[] buf) constructor.

//from   w w  w  .  j  av  a 2  s .  c o  m
import java.io.ByteArrayInputStream;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {

    byte[] buf = { 65, 66, 67, 68, 69 };

    // create new byte array input stream
    ByteArrayInputStream bais = new ByteArrayInputStream(buf);


  }
}