code: public static void copyStream(InputStream input, OutputStream output,
              int buffersize) throws IOException, IllegalArgumentException {
          if (buffersize < 1) {
              throw new IllegalArgumentException(
                      "buffersize must be greater than 0");
          }
          byte[] buffer = new byte[buffersize];
          int n;
          while ((n = input.read(buffer)) >= 0) {
              output.write(buffer, 0, n);
          }
      }
docs: Coping data(binary type) from {@code input} stream to {@code output} stream.
  
  @param input input source of data.
  @param output destination of data.
  @param buffersize size of buffer with is using for data copy.
  @throws IOException if any errors occur during copying process.
  @throws IllegalArgumentException if {@code buffersize} less then 1.