Maybe this is an english language problem by me, I dont't know, but I can't interpret good enough the following sentence on this link:
https://docs.oracle.com/javase/8/docs/api/index.html?java/io/File.html
"public static File createTempFile(String prefix, String suffix) throws IOException
Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. Invoking this method is equivalent to invoking createTempFile(prefix, suffix, null).
The Files.createTempFile method provides an alternative method to create an empty file in the temporary-file directory. Files created by that method may have more restrictive access permissions to files created by this method and so may be more suited to security-sensitive applications."
I cannot interpret this sentence correctly: "Files created by that method may have more restrictive access permissions to files created by this method and so may be more suited to security-sensitive applications."
Is it talking about two different methods? One "may have more restrictive access permissions" than the other one.
But which one is one method, and which one is the other?
createTempFile method
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
7 January 2022, 15:21
in the createTempFile(String, String, File) method it states:
"If the directory argument is null then the system-dependent default temporary-file directory will be used. The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "C:\\WINNT\\TEMP". A different value may be given to this system property when the Java virtual machine is invoked, but programmatic changes to this property are not guaranteed to have any effect upon the temporary directory used by this method."
In the createTempFile(String, String) it is saying that it is similar to using the above method and passing null as the third parameter, but it also states that using that method and passing null to it may have more restrictive access and be better for security. It uses the word "may" to describe, in both methods, that things could occur, such as added security. I don't know exactly what they mean but I assume that "A different value may be given to this system property when the Java virtual machine is invoked" is what they are referring to in the createTempFile(String, String, File) description as the thing that "may have more restrictive access permissions" in the createTempFile(String, String) method description.
0
Gellert Varga
7 January 2022, 23:07
Thank you for your reply! In the meantime, I did a few hours of exploring (detour) into the realm of the System class and Java Properties, and then came back here. Now I immediately noticed the reason for my earlier misunderstanding.
The description in that link is about the createTempFile method of the java.io.File class, while the other method referenced in the description is the createTempFile method of the java.nio.file.Files class.
The package name was not highlighted, only the Files class name, and I didn't notice the single letter difference...
+1