desktop - Java IO Permission Denied. but canWrite is true -


i'm working on small utility supposed insert files program directory. , when comes writing file failes java.io.filenotfoundexception (permission denied)

this code (kind of messy, debugging alot)

while(ze!=null){     string filename = ze.getname();       file newfile = new file(outputfolder + file.separator + filename);        system.out.println("file unzip : "+ newfile.getabsolutefile());         //create non exists folders        //else hit filenotfoundexception compressed folder        new file(newfile.getparent()).mkdirs();        new file(newfile.getparent()).setwritable(true,false);        if(newfile.isdirectory()){            newfile.mkdir();            newfile.getparentfile().setreadonly();            newfile.setreadable(true);            newfile.setexecutable(true);            if(newfile.setwritable(true)){                system.out.println("permission set success");            }else{                system.out.println("permission set failed");            }            newfile.getparentfile().setreadable(true);            newfile.getparentfile().setexecutable(true);            newfile.getparentfile().setwritable(true);             if(newfile.getparentfile().canwrite()){                system.out.println("parent writable");            }else{                system.out.println("parent not writable");                newfile.getparentfile().setwritable(true, false);            }        }         if(!newfile.canwrite()){            system.out.println("we cannot write!");        }else{            system.out.println("we can write!");        fileoutputstream fos = new fileoutputstream(newfile);                      int len;        while ((len = zis.read(buffer)) > 0) {         fos.write(buffer, 0, len);        }         fos.close();           ze = zis.getnextentry();         } }     zis.closeentry(); zis.close();  system.out.println("done"); 

output: file unzip : permission set failed parent writable can write! java.io.filenotfoundexception: (permission denied)

i tried both running app in cmd admin rights , normal user (eclipse) , both fail, can cause of this?


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -