Why does File.createTempFile return a symlink on Mac OS X?
I just found out that on Mac OS X the method File.createTempFile retur开发者_JAVA百科ns a symlink to a file, not an actual file. Does anyone know the reason for this behavior? (Context: This causes my file walker to fail because it ignores all symlinks.)
Edit: I'm calling File.createTempFile(String,String,File), where the third argument is a File created from System.getProperty("java.io.tmpdir").
I'm calling File.createTempFile(String,String,File)
Presumably because it want the file to occupy space in /tmp
or /var/tmp
, but, due to the contract of the method, it needs to put the file in the provided (third argument) directory.
It is important for security reasons to put the file in a designated "temporary" directory such as /tmp
. Many systems have a separate partition for this directory, in order to prevent malicious input to fill up the disk.
精彩评论