0

How can i get this File myTempDir = Files.createTempDir(Path path, String prefix, FileAttribute) to work in windows.

I'm using java 7. On linux I can pass a PosixFilePermissions.asFileAttributes for the 3rd parameter.

What is the equivalent fileAttributes for windows.

I think this method always expects a fileAttribute object. Is there an empty fileAttribute that i can pass in?

0

1 Answer 1

5

If you took a look at the API for
Files.createTempDirectory(Path, String, FileAttribute<?>...), you would actually see that the FileAttribute<?>... parameter is optional:

attrs - an optional list of file attributes to set atomically when creating the directory

And since the method is implemented using varargs, it is perfectly valid to omit the parameter entirely:

Files.createTempDirectory(Paths.get("."), "foo");
Sign up to request clarification or add additional context in comments.

2 Comments

Relevant answer w.r.t. varargs. In any case, this is the "empty file attributes" that OP is looking for, so +1.
There doesn't seem to be a version of Files.createDirectory() that allows you to omit the attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.