code: public static void copy(InputStream from, OutputStream to, int bufferSize) throws IOException {
          byte[] buffer = new byte[bufferSize];
          int read;
          while ((read = from.read(buffer)) > -1) {
              to.write(buffer, 0, read);
          }
      }
docs: Copies an input stream to another stream
  
  @param from       The source of the bytes
  @param to         The destination of the bytes
  @param bufferSize The size of the byte buffer to use as bytes are copied
  @throws IOException Thrown if there is a problem reading from or writing to either stream