开发者

Why does File.createTempFile return a symlink on Mac OS X?

开发者 https://www.devze.com 2023-04-13 08:11 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消