java - Permission Denied When Writing File to Default Temp Directory -
my programme intensive operations, utilize scratch file in order speed things up. utilize next java code:
file scratchfile = new file(system.getproperty("java.io.tmpdir") + "wcctempfile.tmp"); if (!scratchfile.exists()) scratchfile.createnewfile();
this code works fine on mac os x , windows. creates scratch file in java temporary directory, determined operating system.
however, when seek programme on linux (specifically linux mint), next error on line "scratchfile.createnewfile()"
java.io.ioexception: permission denied
i'm confused error because figured temp directory gathered system.getproperty("java.io.tempdir")
method 1 user write (and on other operating systems). not case on linux? there way grant access temp directory? there other directory i'm supposed using?
on linux java.io.tmpdir
commonly set /tmp
(note missing trailing /). instead of messing around embedded slashes, it's lot cleaner utilize the two-parameter file constructor
file scratchfile = new file(system.getproperty("java.io.tmpdir"),"wcctempfile.tmp");
that way don't have worry trailing slashes or not.
java linux tempdir
No comments:
Post a Comment