BufferedInputStream.read(byte[] b, int off, int len) has the following syntax.
public int read(byte[] b, int off, int len) throws IOException
In the following code shows how to use BufferedInputStream.read(byte[] b, int off, int len) method.
/* w w w .j a v a2s . c o m*/ import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.InputStream; public class Main { public static void main(String[] args) throws Exception { InputStream inStream = new FileInputStream("c:/test.txt"); BufferedInputStream bis = new BufferedInputStream(inStream); // read number of bytes available int numByte = bis.available(); // byte array declared byte[] buf = new byte[numByte]; // read byte into buf , starts at offset 2, 3 bytes to read bis.read(buf, 2, 3); // for each byte in buf for (byte b : buf) { System.out.println((char) b + ": " + b); } } }