public static void saveStreamContentAsFile(String fullFileName, InputStream stream) throws IOException {
    fullFileName = findFreeFileName(fullFileName);
    try (OutputStream ostream = new FileOutputStream(fullFileName)) {
      byte[] buf = new byte[8192];

      while (true) {
        int read = stream.read(buf, 0, buf.length);
        if (read == -1) break;
        ostream.write(buf, 0, read);
      }
      ostream.flush();
    }
    new File(fullFileName);
  }
public static void saveStreamContentAsFile(String fullFileName, InputStream stream)