Java IO Tutorial - Java ByteArrayInputStream(byte[] buf, int offset, int length) Constructor








Syntax

ByteArrayInputStream(byte[] buf, int offset, int length) constructor from ByteArrayInputStream has the following syntax.

public ByteArrayInputStream(byte[] buf,     int offset,     int length)

Example

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

//ww w.j  ava 2  s.c om

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, 70 ,71 ,72 ,73 };

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


  }
}