/** create a temporary file that will be deleted on exit, and do something sensible with any IO exceptions - namely, throw them up wrapped in a JenaException. @param prefix the prefix for File.createTempFile @param suffix the suffix for File.createTempFile @return the temporary File */ public static File tempFileName( String prefix, String suffix ) { File result = new File( getTempDirectory(), prefix + randomNumber() + suffix ); if (result.exists()) return tempFileName( prefix, suffix ); result.deleteOnExit(); return result; }
/** create a temporary file that will be deleted on exit, and do something sensible with any IO exceptions - namely, throw them up wrapped in a JenaException. @param prefix the prefix for File.createTempFile @param suffix the suffix for File.createTempFile @return the temporary File */ public static File tempFileName( String prefix, String suffix ) { File result = new File( getTempDirectory(), prefix + randomNumber() + suffix ); if (result.exists()) return tempFileName( prefix, suffix ); result.deleteOnExit(); return result; }
/** Answer a File naming a freshly-created directory in the temporary directory. This directory should be deleted on exit. TODO handle threading issues, mkdir failure, and better cleanup @param prefix the prefix for the directory name @return a File naming the new directory */ public static File getScratchDirectory( String prefix ) { File result = new File( getTempDirectory(), prefix + randomNumber() ); if (result.exists()) return getScratchDirectory( prefix ); if (result.mkdir() == false) throw new JenaException( "mkdir failed on " + result ); result.deleteOnExit(); return result; }
/** Answer a File naming a freshly-created directory in the temporary directory. This directory should be deleted on exit. TODO handle threading issues, mkdir failure, and better cleanup @param prefix the prefix for the directory name @return a File naming the new directory */ public static File getScratchDirectory( String prefix ) { File result = new File( getTempDirectory(), prefix + randomNumber() ); if (result.exists()) return getScratchDirectory( prefix ); if (result.mkdir() == false) throw new JenaException( "mkdir failed on " + result ); result.deleteOnExit(); return result; }