There is a method for reading an array of bytes from the stream, but for some reason it only reads the last cell in the array.
What am I doing wrong?
public void read() { byte[] bytes = { 1, 2, 3, 4 }; try (InputStream in = new ByteArrayInputStream(bytes)) { int b; while ((b = in.read(bytes)) != -1) { System.out.println(b); } } catch (IOException e) { e.printStackTrace(); } } Prints in the console only the number 4 . Why?