code: public static void copyStream(final InputStream src, OutputStream dest) throws IOException {
          byte[] buffer = new byte[1024];
          int read;
          while ((read = src.read(buffer)) > -1) {
              dest.write(buffer, 0, read);
          }
          dest.flush();
      }
docs: Writes the content of an input stream to an output stream
  
  @throws IOException