java - Getting a permission denied error when I have permission -
i'm writing excel spreadsheet file (.xls) directory have permission, xlsoutput directory made @ root of project full permission (right click directory>properties>resource?rwx 3 groups (owner, group, other)
however i'm getting flowing stack trace:
java.io.filenotfoundexception: /xlsoutput (permission denied) @ java.io.fileoutputstream.open(native method) @ java.io.fileoutputstream.<init>(fileoutputstream.java:194) @ java.io.fileoutputstream.<init>(fileoutputstream.java:145) @ jxl.workbook.createworkbook(workbook.java:301) @ jxl.workbook.createworkbook(workbook.java:286) @ com.generalatomics.ctg.taxengine.automation.tools.testhelper.writers.exceltemplatewriter.write(exceltemplatewriter.java:33) @ com.generalatomics.ctg.taxengine.automation.tools.testhelper.testclasses.testxmltoxls(testclasses.java:32) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.testng.internal.methodinvocationhelper.invokemethod(methodinvocationhelper.java:84) @ org.testng.internal.invoker.invokemethod(invoker.java:714) @ org.testng.internal.invoker.invoketestmethod(invoker.java:901) @ org.testng.internal.invoker.invoketestmethods(invoker.java:1231) @ org.testng.internal.testmethodworker.invoketestmethods(testmethodworker.java:127) @ org.testng.internal.testmethodworker.run(testmethodworker.java:111) @ org.testng.testrunner.privaterun(testrunner.java:767) @ org.testng.testrunner.run(testrunner.java:617) @ org.testng.suiterunner.runtest(suiterunner.java:334) @ org.testng.suiterunner.runsequentially(suiterunner.java:329) @ org.testng.suiterunner.privaterun(suiterunner.java:291) @ org.testng.suiterunner.run(suiterunner.java:240) @ org.testng.suiterunnerworker.runsuite(suiterunnerworker.java:52) @ org.testng.suiterunnerworker.run(suiterunnerworker.java:86) @ org.testng.testng.runsuitessequentially(testng.java:1224) @ org.testng.testng.runsuiteslocally(testng.java:1149) @ org.testng.testng.run(testng.java:1057) @ org.testng.remote.remotetestng.run(remotetestng.java:111) @ org.testng.remote.remotetestng.initandrun(remotetestng.java:204) @ org.testng.remote.remotetestng.main(remotetestng.java:175)
not sure why can't write directory? missing obvious? feel am. or assistance appreciated, thanks.
edit:
@test public void testxmltoxls() throws exception { itemplategenerator tgen = new calctemplategenerator(); testtemplate template = tgen.generatetemplate("xmldir"); itemplatewriter writer = new exceltemplatewriter(); string file = "/xlsoutput"; file f = new file(file); logger.debug("can write: "+f.canwrite()); // returns false why?? writer.write(template, file); } public void write ( testtemplate template , string path ) throws exception { cellformat formatheaders = new writablecellformat( new writablefont( writablefont.createfont("calibri"), 12, writablefont.bold ) ); cellformat formattext = new writablecellformat( new writablefont( writablefont.createfont("calibri"), 12, writablefont.no_bold ) ); // create workbook object @ specified path (output directory) writableworkbook workbook = workbook.createworkbook( new file ( path)); // create spreadhseet name of topic , index number @ insert writablesheet sheet = workbook.createsheet( template.gettopic(), 0) ; ...etc }
edit:
figured out....
string file = "xlsoutput/testfile.xls";
i should not have included "/" in front of directory...stupid mistake. helping
you supplied absolute file system path, /xlsoutput
, 1 beginning /
. if omit leading `/', jre interpret being relative system property user.home directory project. try that.
Comments
Post a Comment