java.io.IOException: Permission denied on network folder -
i'm having the post's title error when trying write file on window folder , mounted on unix system. i've developed web service runs inside tomcat 6 on linux os , need write on windows network folder. system administrators have mounted on linux sever , have no problem create , modify file on it. when try execute posted code following exception :
permission denied java.io.ioexception: permission denied @ java.io.unixfilesystem.createfileexclusively(native method) @ java.io.file.createnewfile(file.java:850)
the weird thing seems related file.createnewfile method on network folder , in fact service can write on local file system without problems, both on debug (the pc use develop service) , tomcat folder system administrators have provided me on linux server. file gets created empty , log entry following create method doesn't printed. if use plain outputstream create , write file i've no problems.
i cannot find explanation exception on web. since i'm not experienced java , i'd understand why i'm getting error. using in wrong way ? bug of library ? miss pass parameter ? stated , i've solved problem using plain outputstream, question improve understanding of java.
fileoutputstream fos = null; try{ log.info(string.format("file length: %s",streamattach.length)); log.info(string.format("check file : %s",filename)); file f = new file(filename); if(f.exists()) ... boolean done= f.createnewfile();//here comes exception //nothing of following happens if(!done) throw new nwsexception("error creating file"); log.info(string.format("file %s creato", nomefile));
thank in advance answer
i ran problem , found java.io.file.createnewfile() requires "change permissions" permission (you can find entry under security->advanced when checking folder permissions). without create file , subsequently throw ioexception.
it's deceptive because still able create files on folder when manually testing, createnewfile() still fail if doesn't have particular permission (presumably such can change permissions on file creating).
Comments
Post a Comment