/**
* Create a temporary file,
* Slightly smarter version of File.createTempFile
*
* @param prefix beginning letters of filename
* @param suffix ending letters of filename.
* @param near directory where to put file, or file to
* place this temp file near in the same directory.
* null means put the temp file in the
* current directory.
* @return A temporary file. It will not automatically
* delete on program completion, however.
* @exception IOException
*/
public static File createTempFile ( String prefix , String suffix , File near ) throws IOException {
if ( near != null )
{
if ( near.isDirectory() )
{
return File.createTempFile ( prefix, suffix, near );
}
else if ( near.isFile() )
{
String parent = near.getParent();
if ( parent != null )
{
File dir = new File( parent );
if ( dir.isDirectory() )
{
return File.createTempFile ( prefix, suffix, dir );
}
}
}
}
return File.createTempFile ( prefix, suffix );
}