diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index 0c39d2389..da5dce07a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -1190,8 +1190,7 @@ public class Execute { */ private File createCommandFile(String[] cmd, String[] env) throws IOException { - File script = FILE_UTILS.createTempFile("ANT", ".COM", null); - script.deleteOnExit(); + File script = FILE_UTILS.createTempFile("ANT", ".COM", null, true, true); PrintWriter out = null; try { out = new PrintWriter(new FileWriter(script)); diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index b8946edc3..8b95ddfa9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -343,7 +343,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { fcv = new Vector(1); fcv.add(fc); } - File tmpFile = FILE_UTILS.createTempFileName("fixcrlf", "", null, true); + File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, false); try { FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false, false, encoding, outputEncoding == null ? encoding : outputEncoding, diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 69da5505c..5074a4150 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -1694,8 +1694,7 @@ public class Javadoc extends Task { * if requested. */ if (useExternalFile) { - tmpList = FILE_UTILS.createTempFile("javadoc", "", null); - tmpList.deleteOnExit(); + tmpList = FILE_UTILS.createTempFile("javadoc", "", null, true, true); toExecute.createArgument() .setValue("@" + tmpList.getAbsolutePath()); srcListWriter = new PrintWriter( @@ -1882,8 +1881,7 @@ public class Javadoc extends Task { PrintWriter optionsListWriter = null; try { optionsTmpFile = FILE_UTILS.createTempFile( - "javadocOptions", "", null); - optionsTmpFile.deleteOnExit(); + "javadocOptions", "", null, true, true); String[] listOpt = toExecute.getArguments(); toExecute.clearArgs(); toExecute.createArgument().setValue( diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java index c536bf1ca..ee8e48798 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -600,7 +600,7 @@ public class Replace extends MatchingTask { in = new FileInput(src); temp = FILE_UTILS.createTempFile("rep", ".tmp", - src.getParentFile()); + src.getParentFile(), false, true); out = new FileOutput(temp); int repCountStart = replaceCount; diff --git a/src/main/org/apache/tools/ant/taskdefs/TempFile.java b/src/main/org/apache/tools/ant/taskdefs/TempFile.java index 96f5cdc04..f768361ca 100644 --- a/src/main/org/apache/tools/ant/taskdefs/TempFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/TempFile.java @@ -155,15 +155,8 @@ public class TempFile extends Task { if (destDir == null) { destDir = getProject().resolveFile("."); } - File tfile; - if (createFile) { - tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir, - deleteOnExit); - } else { - tfile = FILE_UTILS.createTempFileName(prefix, suffix, destDir, - deleteOnExit); - } - + File tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir, + deleteOnExit, createFile); getProject().setNewProperty(property, tfile.toString()); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 1a8544e99..8e04932c1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -579,8 +579,8 @@ public class Zip extends MatchingTask { /** rename the zip file. */ private File renameFile() { - File renamedFile = FILE_UTILS.createTempFileName( - "zip", ".tmp", zipFile.getParentFile(), true); + File renamedFile = FILE_UTILS.createTempFile( + "zip", ".tmp", zipFile.getParentFile(), true, false); try { FILE_UTILS.rename(zipFile, renamedFile); } catch (SecurityException e) { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index edcda4798..13275ccba 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -466,8 +466,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { PrintWriter out = null; try { tmpFile = FILE_UTILS.createTempFile( - "files", "", getJavac().getTempdir()); - tmpFile.deleteOnExit(); + "files", "", getJavac().getTempdir(), true, true); out = new PrintWriter(new FileWriter(tmpFile)); for (int i = firstFileName; i < args.length; i++) { if (quoteFiles && args[i].indexOf(" ") > -1) { diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java index 96805b51b..afb3cb3dd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java +++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java @@ -224,8 +224,7 @@ public class CvsTagDiff extends AbstractCvsTask { setCommand(""); File tmpFile = null; try { - tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null); - tmpFile.deleteOnExit(); + tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null, true, true); setOutput(tmpFile); // run the cvs command diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java index c3a6b6a57..4bfb05497 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java @@ -177,8 +177,7 @@ public class Cab extends MatchingTask { */ protected File createListFile(Vector files) throws IOException { - File listFile = FILE_UTILS.createTempFile("ant", "", null); - listFile.deleteOnExit(); + File listFile = FILE_UTILS.createTempFile("ant", "", null, true, true); PrintWriter writer = new PrintWriter(new FileOutputStream(listFile)); @@ -314,8 +313,7 @@ public class Cab extends MatchingTask { exec.setDir(baseDir); if (!doVerbose) { - outFile = FILE_UTILS.createTempFile("ant", "", null); - outFile.deleteOnExit(); + outFile = FILE_UTILS.createTempFile("ant", "", null, true, true); exec.setOutput(outFile); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java index b769e8a30..01baa444e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java @@ -323,8 +323,7 @@ public class ReplaceRegExp extends Task { */ protected void doReplace(File f, int options) throws IOException { - File temp = FILE_UTILS.createTempFile("replace", ".txt", null); - temp.deleteOnExit(); + File temp = FILE_UTILS.createTempFile("replace", ".txt", null, true, true); Reader r = null; Writer w = null; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java index 39fa886e1..6ff45e3a9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java @@ -346,7 +346,7 @@ public class NetCommand { //afterwards FileOutputStream fos = null; - temporaryCommandFile = FILE_UTILS.createTempFile("cmd", ".txt", null); + temporaryCommandFile = FILE_UTILS.createTempFile("cmd", ".txt", null, false, true); owner.log("Using response file " + temporaryCommandFile, Project.MSG_VERBOSE); try { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index d7830c2e5..14afac557 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -1145,7 +1145,7 @@ public class JUnitTask extends Task { private File createTempPropertiesFile(String prefix) { File propsFile = FILE_UTILS.createTempFile(prefix, ".properties", - tmpDir != null ? tmpDir : getProject().getBaseDir(), true); + tmpDir != null ? tmpDir : getProject().getBaseDir(), true, true); return propsFile; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 4260d8fcc..56693aad1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -1827,9 +1827,9 @@ public class FTP FTPFile [] theFiles = null; final int maxIterations = 1000; for (int counter = 1; counter < maxIterations; counter++) { - File localFile = FILE_UTILS.createTempFileName( + File localFile = FILE_UTILS.createTempFile( "ant" + Integer.toString(counter), ".tmp", - null, false); + null, false, false); String fileName = localFile.getName(); boolean found = false; try { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java index bf1f86aa5..d594f7bc1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java @@ -409,8 +409,8 @@ public class Symlink extends DispatchTask { File canfil = linkfil.getCanonicalFile(); // rename the resource, thus breaking the link: - File temp = FILE_UTILS.createTempFileName("symlink", ".tmp", - canfil.getParentFile(), false); + File temp = FILE_UTILS.createTempFile("symlink", ".tmp", + canfil.getParentFile(), false, false); try { try { FILE_UTILS.rename(canfil, temp); diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java index 86e6c5210..9fa8c6875 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java @@ -449,7 +449,7 @@ public class ModifiedSelector extends BaseExtendSelector // How to handle non-file-Resources? I copy temporarily the // resource to a file and use the file-implementation. FileUtils fu = FileUtils.getFileUtils(); - File tmpFile = fu.createTempFileName("modified-", ".tmp", null, true); + File tmpFile = fu.createTempFile("modified-", ".tmp", null, true, false); Resource tmpResource = new FileResource(tmpFile); ResourceUtils.copyResource(resource, tmpResource); boolean isSelected = isSelected(tmpFile.getParentFile(), diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index adad6d22d..6c3d06c33 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -784,24 +784,32 @@ public class FileUtils { } /** - * Create a temporary file in a given directory. - * - *
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.
- * - *As of ant 1.8 the file is actually created.
- * - * @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. - * - * @return a File reference to the new temporary file. - * @since Ant 1.5 + * Create a File object for a temporary file in a given directory. Without + * actually creating the file. + * + *+ * 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. + *
+ *+ * The filename is prefixNNNNNsuffix where NNNN is a random number. + *
+ * + * @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.8 use createTempFile(String, String, File, + * boolean, boolean) instead. + * @return a File reference to the new, nonexistent temporary file. */ public File createTempFile(String prefix, String suffix, File parentDir) { - return createTempFile(prefix, suffix, parentDir, false); + return createTempFile(prefix, suffix, parentDir, false, false); } /** @@ -811,29 +819,43 @@ public class FileUtils { * exist before this method was invoked, any subsequent invocation * of this method will yield a different file name. * - *As of ant 1.8 the file is actually created.
- * * @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. * @param deleteOnExit whether to set the tempfile for deletion on * normal VM exit. + * @param createFile true if the file must actually be created. If false + * chances exist that a file with the same name is created in the time + * between invoking this method and the moment the file is actually created. + * If possible set to true. * * @return a File reference to the new temporary file. - * @since Ant 1.7 + * @since Ant 1.8 */ public File createTempFile(String prefix, String suffix, File parentDir, - boolean deleteOnExit) { + boolean deleteOnExit, boolean createFile) { File result = null; - String parent = (parentDir == null) - ? System.getProperty("java.io.tmpdir") - : parentDir.getPath(); - try { - result = File.createTempFile(prefix, suffix, new File(parent)); - } catch (IOException e) { - throw new BuildException("Could not create tempfile in " + parent, e); + String parent = (parentDir == null) ? System + .getProperty("java.io.tmpdir") : parentDir.getPath(); + + if (createFile) { + try { + result = File.createTempFile(prefix, suffix, new File(parent)); + } catch (IOException e) { + throw new BuildException("Could not create tempfile in " + + parent, e); + } + } else { + DecimalFormat fmt = new DecimalFormat("#####"); + synchronized (rand) { + do { + result = new File(parent, prefix + + fmt.format(Math.abs(rand.nextInt())) + suffix); + } while (result.exists()); + } } + if (deleteOnExit) { result.deleteOnExit(); } @@ -843,41 +865,33 @@ public class FileUtils { /** * Create a File object for a temporary file in a given directory. Without * actually creating the file. - * - *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.
+ * + *+ * 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. + *
** The filename is prefixNNNNNsuffix where NNNN is a random number. *
- * - * @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. - * @param deleteOnExit whether to set the tempfile for deletion on - * normal VM exit. - * + * + * @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. + * @param deleteOnExit + * whether to set the tempfile for deletion on normal VM exit. + * + * @deprecated since ant 1.8 use createTempFile(String, String, File, + * boolean, boolean) instead. * @return a File reference to the new, nonexistent temporary file. - * @since Ant 1.8 */ - public File createTempFileName(String prefix, String suffix, + public File createTempFile(String prefix, String suffix, File parentDir, boolean deleteOnExit) { - File result = null; - String parent = (parentDir == null) ? System - .getProperty("java.io.tmpdir") : parentDir.getPath(); - - DecimalFormat fmt = new DecimalFormat("#####"); - synchronized (rand) { - do { - result = new File(parent, prefix - + fmt.format(Math.abs(rand.nextInt())) + suffix); - } while (result.exists()); - } - if (deleteOnExit) { - result.deleteOnExit(); - } - return result; + return createTempFile(prefix, suffix, parentDir, deleteOnExit, false); } /** diff --git a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java index 859573038..37ea25786 100644 --- a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java +++ b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java @@ -440,7 +440,7 @@ public final class JavaEnvUtils { */ public static File createVmsJavaOptionFile(String[] cmd) throws IOException { - File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null); + File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null, false, true); PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter(script))); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java index a4e7eda88..d3a143f22 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java @@ -347,7 +347,7 @@ public class ExecTaskTest extends BuildFileTest { return; } myBuild = new MonitoredBuild(new File(System.getProperty("root"), BUILD_FILE), "spawn"); - logFile = FILE_UTILS.createTempFileName("spawn","log", project.getBaseDir(), false); + logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir(), false, false); // this is guaranteed by FileUtils#createTempFile assertTrue("log file not existing", !logFile.exists()); // make the spawned process run 4 seconds diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java index 1cc2089bc..a5ae68622 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java @@ -175,7 +175,7 @@ public class JavaTest extends BuildFileTest { } public void testSpawn() { - File logFile = FILE_UTILS.createTempFileName("spawn","log", project.getBaseDir(), false); + File logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir(), false, false); // this is guaranteed by FileUtils#createTempFile assertTrue("log file not existing", !logFile.exists()); project.setProperty("logFile", logFile.getAbsolutePath()); diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java index d25dd138a..e3265eccf 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java @@ -390,7 +390,7 @@ public class ModifiedSelectorTest extends BaseSelectorTest { * configure() method of ModifiedSelector. This testcase tests that. */ public void testCreatePropertiesCacheViaCustomSelector() { - File cachefile = FILE_UTILS.createTempFileName("tmp-cache-", ".properties", null, false); + File cachefile = FILE_UTILS.createTempFile("tmp-cache-", ".properties", null, false, false); try { // initialize test environment (called "bed") makeBed(); diff --git a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java index 27b5c3d3a..baeffb794 100644 --- a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java @@ -342,55 +342,50 @@ public class FileUtilsTest extends TestCase { */ public void testCreateTempFile() { - // null parent dir - File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", null, false); - String tmploc = System.getProperty("java.io.tmpdir"); - String name = tmp1.getName(); - assertTrue("starts with pre", name.startsWith("pre")); - assertTrue("ends with .suf", name.endsWith(".suf")); - assertTrue("File was created", tmp1.exists()); - assertEquals((new File(tmploc, tmp1.getName())).getAbsolutePath(), - tmp1.getAbsolutePath()); - tmp1.delete(); - - File dir2 = new File(tmploc+"/ant-test"); - dir2.mkdir(); - removeThis = dir2; - - File tmp2 = FILE_UTILS.createTempFile("pre", ".suf", dir2, true); - String name2 = tmp2.getName(); - assertTrue("starts with pre", name2.startsWith("pre")); - assertTrue("ends with .suf", name2.endsWith(".suf")); - assertTrue("File was created", tmp2.exists()); - assertEquals((new File(dir2, tmp2.getName())).getAbsolutePath(), - tmp2.getAbsolutePath()); - tmp2.delete(); - dir2.delete(); - } - /** - * Test createTempFileName - */ - public void testCreateTempFileName() { + // null parent dir + File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", null, false, true); + String tmploc = System.getProperty("java.io.tmpdir"); + String name = tmp1.getName(); + assertTrue("starts with pre", name.startsWith("pre")); + assertTrue("ends with .suf", name.endsWith(".suf")); + assertTrue("File was created", tmp1.exists()); + assertEquals((new File(tmploc, tmp1.getName())).getAbsolutePath(), tmp1 + .getAbsolutePath()); + tmp1.delete(); + + File dir2 = new File(tmploc + "/ant-test"); + dir2.mkdir(); + removeThis = dir2; + + File tmp2 = FILE_UTILS.createTempFile("pre", ".suf", dir2, true, true); + String name2 = tmp2.getName(); + assertTrue("starts with pre", name2.startsWith("pre")); + assertTrue("ends with .suf", name2.endsWith(".suf")); + assertTrue("File was created", tmp2.exists()); + assertEquals((new File(dir2, tmp2.getName())).getAbsolutePath(), tmp2 + .getAbsolutePath()); + tmp2.delete(); + dir2.delete(); + File parent = new File((new File("/tmp")).getAbsolutePath()); - File tmp1 = FILE_UTILS.createTempFileName("pre", ".suf", parent, false); + tmp1 = FILE_UTILS.createTempFile("pre", ".suf", parent, false); assertTrue("new file", !tmp1.exists()); - String name = tmp1.getName(); + name = tmp1.getName(); assertTrue("starts with pre", name.startsWith("pre")); assertTrue("ends with .suf", name.endsWith(".suf")); - assertEquals("is inside parent dir", - parent.getAbsolutePath(), - tmp1.getParent()); + assertEquals("is inside parent dir", parent.getAbsolutePath(), tmp1 + .getParent()); - File tmp2 = FILE_UTILS.createTempFileName("pre", ".suf", parent, false); - assertTrue("files are different", - !tmp1.getAbsolutePath().equals(tmp2.getAbsolutePath())); + tmp2 = FILE_UTILS.createTempFile("pre", ".suf", parent, false); + assertTrue("files are different", !tmp1.getAbsolutePath().equals( + tmp2.getAbsolutePath())); // null parent dir - File tmp3 = FILE_UTILS.createTempFileName("pre", ".suf", null, false); - String tmploc = System.getProperty("java.io.tmpdir"); - assertEquals((new File(tmploc, tmp3.getName())).getAbsolutePath(), - tmp3.getAbsolutePath()); + File tmp3 = FILE_UTILS.createTempFile("pre", ".suf", null, false); + tmploc = System.getProperty("java.io.tmpdir"); + assertEquals((new File(tmploc, tmp3.getName())).getAbsolutePath(), tmp3 + .getAbsolutePath()); } /**