Copy (in, out) method in Java on buffering byte[]buffer

  java, question

The internal buffer byte[]buffer has a defined size of 4096. What if the io stream content to be written exceeds this size
Post a source code:

public static int copy(InputStream input, OutputStream output) throws IOException {
 long count = copyLarge(input, output);
 if (count > Integer.MAX_VALUE) {
 return -1;
 bracket
 return (int) count;
 bracket
 
 public static long copyLarge(InputStream input, OutputStream output)
 throws IOException {
 return copyLarge(input, output, new byte[DEFAULT_BUFFER_SIZE]);  //Size 4096
 bracket
 
 public static long copyLarge(InputStream input, OutputStream output, byte[] buffer)
 throws IOException {
 long count = 0;
 int n = 0;
 while (EOF !  = (n = input.read(buffer))) {
 output.write(buffer, 0, n);
 Count plus = n;
 bracket
 return count;
 bracket

I don’t see any other treatment for buffer. What if buffer is not big enough?

The key is here.while (EOF ! = (n = input.read(buffer)))
The document inside said:

public int read(byte[] b) throws IOException

Reads a certain number of bytes from the input stream and stores them in buffer array b. Returns the actual number of bytes read as an integer. This method blocks until input data is available, the end of the file is detected, or an exception is thrown.
If the length of B is 0, no bytes are read and 0 is returned; Otherwise, try reading at least one byte. If there are no bytes available because the stream is at the end of the file, return value-1; Otherwise, at least one byte is read and stored in b.
The first byte read is stored in element b[0], the next byte is stored in b[1], and so on.The number of bytes read is at most equal to the length of b.Let k be the number of bytes actually read; These bytes will be stored in elements of b[0] to b[k-1], without affecting elements of b[k] to b[b.length-1].
The read(b) method of class InputStream has the same effect as:
read(b, 0, b.length)

That is to say, a maximum of 4096 bytes are read at a time. If more than 4096 bytes are read, the while loop will read many times.