set tmpfile.deleteOnExit by default,

to make sure files are removed on shutdown.
pull/27/head
reger 9 years ago
parent 2985baaa01
commit 02e4489a23

@ -271,7 +271,6 @@ public class psParser extends AbstractParser implements Parser {
try {
// creating a tempfile
tempFile = FileUtils.createTempFile(this.getClass(), "temp.ps");
tempFile.deleteOnExit();
// copying inputstream into file
FileUtils.copy(source,tempFile);

@ -790,6 +790,16 @@ public final class FileUtils {
}
}
/**
* Creates a temp file in the default system tmp directory (System property ""java.io.tmpdir"")
* with a name constructed by combination of class name and name.
* Marks the file with deleteOnExit() to be at least deleted on shutdown of jvm
*
* @param classObj name is used as prefix
* @param name
* @return temp file
* @throws IOException
*/
public static final File createTempFile(final Class<?> classObj, final String name) throws IOException {
String parserClassName = classObj.getName();
int idx = parserClassName.lastIndexOf('.');
@ -809,6 +819,7 @@ public final class FileUtils {
File.createTempFile(
parserClassName + "_" + ((idx > -1) ? fileName.substring(0, idx) : fileName),
(!fileExt.isEmpty()) ? "." + fileExt : fileExt);
tempFile.deleteOnExit();
return tempFile;
}

Loading…
Cancel
Save