/** * utility method to get a tmp file in the current user directory of the provided * directory * * @param fileOrDirPath path to a file or directory to use as temp location (use parent directory * if a file is provided) */ protected static File getTempFile(String fileOrDirPath) throws IOException { if (fileOrDirPath != null) { return getTempFile(new File(fileOrDirPath)); } else { return getTempFile((File) null); } }
/** * utility method to get a tmp file in the current user directory of the provided * directory * * @param fileOrDirPath path to a file or directory to use as temp location (use parent directory * if a file is provided) */ protected static File getTempFile(String fileOrDirPath) throws IOException { if (fileOrDirPath != null) { return getTempFile(new File(fileOrDirPath)); } else { return getTempFile((File) null); } }
public void saveRuntimeInfo(File output) throws IOException { // if output file is null, we overwrite the current archive... File outputFile = output; if (outputFile == null) { outputFile = getTempFile(path); } // copy all entries from source to target except the // runtime descriptor file WritableArchive out = archiveFactory.createArchive(outputFile); ReadableArchive in = archiveFactory.openArchive(new File(path)); Vector skipFiles = new Vector(); skipFiles.add(getRuntimeDeploymentDescriptorPath()); copyInto(in, out, skipFiles); in.close(); // now save the runtime deployment descriptor... OutputStream os = out.putNextEntry(getRuntimeDeploymentDescriptorPath()); writeRuntimeDeploymentDescriptors(os); out.closeEntry(); out.close(); // if we overwrote the old archive, need to rename the tmp now if (output == null) { ReadableArchive finalArchive = archiveFactory.openArchive(new File(path)); finalArchive.delete(); ReadableArchive tmpArchive = archiveFactory.openArchive(outputFile); tmpArchive.renameTo(path); } }
outputFile = getTempFile(outPath); outputFile.delete(); out = archiveFactory.createArchive(outputFile);
outputFile = getTempFile(outPath); outputFile.delete(); out = archiveFactory.createArchive(outputFile);