/** * Create a File object for a temporary file in a given directory. Without * actually creating the file. * * <p> * The file denoted by the returned abstract pathname did not exist before * this method was invoked, any subsequent invocation of this method will * yield a different file name. * </p> * <p> * The filename is prefixNNNNNsuffix where NNNN is a random number. * </p> * * @param prefix * prefix before the random number. * @param suffix * file extension; include the '.'. * @param parentDir * Directory to create the temporary file in; java.io.tmpdir used * if not specified. * * @deprecated since ant 1.7.1 use createTempFile(String, String, File, * boolean, boolean) instead. * @return a File reference to the new, nonexistent temporary file. */ @Deprecated public File createTempFile(String prefix, String suffix, File parentDir) { return createTempFile(prefix, suffix, parentDir, false, false); }
public File createTempFile(String prefix, String suffix, File parentDir, boolean deleteOnExit) { return createTempFile(prefix, suffix, parentDir, deleteOnExit, false);
/** rename the zip file. */ private File renameFile() { final File renamedFile = FILE_UTILS.createTempFile( "zip", ".tmp", zipFile.getParentFile(), true, false); try { FILE_UTILS.rename(zipFile, renamedFile); } catch (final SecurityException | IOException e) { throw new BuildException( "Unable to rename old file (%s) to temporary file", zipFile.getAbsolutePath()); } return renamedFile; }
/** * Writes the command into a temporary DCL script and returns the * corresponding File object. * It is the job of the caller to delete the file on exit. * @param cmds the command. * @return the file containing the command. * @throws IOException if there is an error writing to the file. */ public static File createVmsJavaOptionFile(String[] cmds) throws IOException { File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null, false, true); try (BufferedWriter out = new BufferedWriter(new FileWriter(script))) { for (String cmd : cmds) { out.write(cmd); out.newLine(); } } return script; }
/** * Creates a list file. This temporary file contains a list of all files * to be included in the cab, one file per line. * * <p>This method expects to only be called on Windows and thus * quotes the file names.</p> * @param files the list of files to use. * @return the list file created. * @throws IOException if there is an error. */ protected File createListFile(Vector<String> files) throws IOException { File listFile = FILE_UTILS.createTempFile("ant", "", null, true, true); try (BufferedWriter writer = new BufferedWriter(new FileWriter(listFile))) { for (String f : files) { String s = String.format("\"%s\"", f); writer.write(s); writer.newLine(); } } return listFile; }
private File createCommandFile(String[] cmd, String[] env) throws IOException { File script = FILE_UTILS.createTempFile("ANT", ".COM", null, true, true); try (BufferedWriter out = new BufferedWriter(new FileWriter(script))) { // add the environment as logicals to the DCL script if (env != null) { int eqIndex; for (String variable : env) { eqIndex = variable.indexOf('='); if (eqIndex != -1) { out.write("$ DEFINE/NOLOG "); out.write(variable.substring(0, eqIndex)); out.write(" \""); out.write(variable.substring(eqIndex + 1)); out.write('\"'); out.newLine(); } } } out.write("$ " + cmd[0]); for (int i = 1; i < cmd.length; i++) { out.write(" -"); out.newLine(); out.write(cmd[i]); } } return script; }
private void createNewArgs(String txt) throws IOException { final String[] args = cmdline.getCommandline(); // Temporary file - delete on exit, create (assured unique name). final File tempFile = FileUtils.getFileUtils().createTempFile(PREFIX, SUFFIX, null, true, true); final String[] commandline = new String[args.length + 1]; ResourceGroovyMethods.write(tempFile, txt); commandline[0] = tempFile.getCanonicalPath(); System.arraycopy(args, 0, commandline, 1, args.length); super.clearArgs(); for (String arg : commandline) { final Commandline.Argument argument = super.createArg(); argument.setValue(arg); } }
/** * Creates the temporary file. * * @exception BuildException if something goes wrong with the build */ @Override public void execute() throws BuildException { if (property == null || property.isEmpty()) { throw new BuildException("no property specified"); } if (destDir == null) { destDir = getProject().resolveFile("."); } File tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir, deleteOnExit, createFile); getProject().setNewProperty(property, tfile.toString()); } }
optionsTmpFile = FILE_UTILS.createTempFile( "javadocOptions", "", null, true, true); final String[] listOpt = toExecute.getArguments();
BufferedWriter out = null; try { tmpFile = FileUtils.getFileUtils().createTempFile("jikes", "tmp", null, false, true); out = new BufferedWriter(new FileWriter(tmpFile));
final File temp = FILE_UTILS.createTempFile("symlink", ".tmp", target.getParentFile(), false, false);
File temp = FILE_UTILS.createTempFile("replace", ".txt", null, true, true); try { boolean changes = false;
File temp = FILE_UTILS.createTempFile("rep", ".tmp", src.getParentFile(), false, true); try {
fcv.add(fc); File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, true); try { FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, true, false,
&& firstFileName >= 0) { try { tmpFile = FILE_UTILS.createTempFile( "files", "", getJavac().getTempdir(), true, true); try (BufferedWriter out =
File tmpFile = fu.createTempFile("modified-", ".tmp", null, true, false); Resource tmpResource = new FileResource(tmpFile); ResourceUtils.copyResource(resource, tmpResource);
outFile = FILE_UTILS.createTempFile("ant", "", null, true, true); exec.setOutput(outFile);
handlePackageNames(); tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null, true, true); setOutput(tmpFile);
tmpList = FILE_UTILS.createTempFile("javadoc", "", null, true, true); toExecute.createArgument() .setValue("@" + tmpList.getAbsolutePath());
/** * Create a temporary file to pass the properties to a new process. * Will auto-delete on (graceful) exit. * The file will be in the project basedir unless tmpDir declares * something else. * @param prefix String * @return created file */ private File createTempPropertiesFile(final String prefix) { return FILE_UTILS.createTempFile(prefix, ".properties", tmpDir != null ? tmpDir : getProject().getBaseDir(), true, true); }