code: public File saveAs(File destFile, boolean overwrite) throws IOException {
          if (destFile == null) {
              throw new IllegalArgumentException("destFile can not be null");
          }
  
          try {
              destFile = determineDestinationFile(destFile, overwrite);
  
              final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
              int len;
              try (InputStream input = getInputStream(); OutputStream output = new FileOutputStream(destFile)) {
                  while ((len = input.read(buffer)) != -1) {
                      output.write(buffer, 0, len);
                  }
              }
          } catch (Exception e) {
              throw new IOException("Could not save as file " + destFile, e);
          }
  
          setSavedFile(destFile);
          return destFile;
      }
docs: Save an file as a given destination file.
  
  @param destFile the destination file
  @param overwrite whether to overwrite if it already exists
  @return a saved file
  @throws IOException if an I/O error has occurred