Write, replace or update the catalog jar based on different cases. This function
assumes any IOException should lead to fatal crash.
@param path
@param name
@throws IOException
772057
public Runnable writeCatalogJarToFile(String path, String name, CatalogJarWriteMode mode) throws IOException
    {
        File catalogFile = new VoltFile(path, name);
        File catalogTmpFile = new VoltFile(path, name + ".tmp");

        if (mode == CatalogJarWriteMode.CATALOG_UPDATE) {
            // This means a @UpdateCore case, the asynchronous writing of
            // jar file has finished, rename the jar file
            catalogFile.delete();
            catalogTmpFile.renameTo(catalogFile);
            return null;
        }

        if (mode == CatalogJarWriteMode.START_OR_RESTART) {
            // This happens in the beginning of ,
            // when the catalog jar does not yet exist. Though the contents
            // written might be a default one and could be overwritten later
            // by @UAC, @UpdateClasses, etc.
            return m_catalogInfo.m_jarfile.writeToFile(catalogFile);
        }

        if (mode == CatalogJarWriteMode.RECOVER) {
            // we must overwrite the file (the file may have been changed)
            catalogFile.delete();
            if (catalogTmpFile.exists()) {
                // If somehow the catalog temp jar is not cleaned up, then delete it
                catalogTmpFile.delete();
            }

            return m_catalogInfo.m_jarfile.writeToFile(catalogFile);
        }

        VoltDB.crashLocalVoltDB("Unsupported mode to write catalog jar", true, null);
        return null;
    }
400440
public static void write(InputStream in, Path path) {
        write(in, path, StandardCopyOption.REPLACE_EXISTING);
    }
91154
@Override
    public void writeCatalogJar(byte[] catalogBytes) throws IOException
    {
        File configInfoDir = getConfigDirectory();
        configInfoDir.mkdirs();

        InMemoryJarfile.writeToFile(catalogBytes,
                                    new VoltFile(configInfoDir.getPath(),
                                                 InMemoryJarfile.TMP_CATALOG_JAR_FILENAME));
    }
1094534
public static void writeTo(String path) throws IOException, NoSuchMethodException, IllegalAccessException,
            InvocationTargetException {
        MsUtils.writeTo(xssfWorkbook, path);
    }
792372
private void addProjectPath(final Path path) {
        addToClassPool(path);

        if (path.toFile().isFile() && path.toString().endsWith(".jar")) {
            addJarClasses(path);
        } else if (path.toFile().isDirectory()) {
            addDirectoryClasses(path, Paths.get(""));
        } else {
            throw new IllegalArgumentException("The project path '" + path + "' must be a jar file or a directory");
        }
    }
406964
public static void renamePath(FileContext fc, Path oldName, Path newName, boolean overwrite)
      throws IOException {
    Options.Rename renameOptions = (overwrite) ? Options.Rename.OVERWRITE : Options.Rename.NONE;
    fc.rename(oldName, newName, renameOptions);
  }
1215164
public void writeStartList(String name) throws IOException
   {
      writeComma();
      writeNewLineIndent();
      writeName(name);
      writeNewLineIndent();
      m_writer.write("[");
      increaseIndent();
   }
355428
public static void writeTo(String path) throws IOException, NoSuchMethodException, IllegalAccessException,
            InvocationTargetException {
        createXwpfDocumentIfNull();
        MsUtils.writeTo(xwpfDocument, path);
    }
1064132
public void mkPackage(String name) throws IOException {
        File metaDir = new File(getAssetLoc() + "/" + name.replace('.', '/') + "/.mdw");
        if (!metaDir.exists() && !metaDir.mkdirs())
            throw new IOException("Cannot create directory: " + metaDir.getAbsolutePath());
        File pkgFile = new File(metaDir + "/package.yaml");
        if (!pkgFile.exists()) {
            JSONObject pkgJson = new JSONObject();
            pkgJson.put("name", name);
            pkgJson.put("version", "1.0.01");
            pkgJson.put("schemaVersion", "6.1");
            Files.write(Paths.get(pkgFile.getPath()), pkgJson.toString(2).getBytes());
        }
    }
3760
public static ClassFileReader newInstance(Path path) throws IOException {
        if (!Files.exists(path)) {
            throw new FileNotFoundException(path.toString());
        }

        if (Files.isDirectory(path)) {
            return new DirectoryReader(path);
        } else if (path.getFileName().toString().endsWith(".jar")) {
            return new JarFileReader(path);
        } else {
            return new ClassFileReader(path);
        }
    }
1196819
public void setClasspath(Path classpath) {
        if (compileClasspath == null) {
            compileClasspath = classpath;
        } else {
            compileClasspath.append(classpath);
        }
    }
905860
private File createNewFile(String path) throws IOException {

		// In windows, pathnames with spaces are returned as %20
		if (path.contains("%20"))
			path = path.replaceAll("%20", " ");
		File newFile = new File(path);

		if (!newFile.exists() && !newFile.createNewFile()) {
			throw new BundlingProcessException("Unable to create a temporary file at " + path);
		}

		if (LOGGER.isDebugEnabled())
			LOGGER.debug("Created file: " + newFile.getCanonicalPath());
		return newFile;
	}
938698
public final void writeTo(String path) throws IOException {
        final int i = path.lastIndexOf(DOT);
        if (i < 0 || i + 1 == path.length())
            throw new IOException("Cannot find suffix in provided path: " + path);
        final String fmt = path.substring(i + 1);
        writeTo(fmt, path);
    }
713562
def save(path)
      update
      Zip::OutputStream.open(path) do |out|
        zip.each do |entry|
          next unless entry.file?
          out.put_next_entry(entry.name)

          if @replace[entry.name]
            out.write(@replace[entry.name])
          else
            out.write(zip.read(entry.name))
          end
        end
      end
      zip.close
    end
667794
public void setPath( String path )
    {
        // Note that an empty path is OK
        if ( path == null )
        {
            _path = null;
            setQuery( null );
            setFragment( null );
        }
        else
        {
            _path = path;
            _opaque = false;
            setSchemeSpecificPart( null );
        }
    }
971357
public final void writeTo(String fmt, String path) throws IOException {
        writeTo(fmt, new File(replaceTildeWithHomeDir(ensureSuffix(path, fmt))));
    }
720485
private static void createDirectory(Path path) throws IOException {
		try {
			Files.createDirectory(path);
		} catch (FileAlreadyExistsException e) {
			if (!Files.isDirectory(path)) {
				throw e;
			}
		}
	}