java - access denied to access to /etc/hosts -
i can't access hosts file of windows java (just write) :
java.io.filenotfoundexception: c:\windows\system32\drivers\etc\hosts (access denied) @ java.io.fileoutputstream.open(native method)
when want append text hosts file above error ...
this code :
bufferedwriter bw = null; try { // append mode set here bw = new bufferedwriter(new filewriter(file,true)); bw.write(text); bw.newline(); bw.flush(); } catch(filenotfoundexception e) { e.printstacktrace(); } catch (ioexception ioe) { ioe.printstacktrace(); } { try { // close file bw.close(); } catch (ioexception ex) { logger.getlogger(filewrite.class.getname()).log(level.severe, null, ex); } } } // end test()
this code work simple files in other location of windows .. (just error on c:\windows\ ...
and : use microsoft manifest set administration access [not work]
set full access hosts file [not work]
please ..
tnx
check if java running administrator (i.e. write new file in same folder). there access problem , solve need understand (user/service of app) , permissions of resource (file) trying access.
here 2 ways how can try , debug it: 1) don't have permissions write file (can read it?) 2) don't have permissions enter folder (can list files in it)
Comments
Post a Comment