java - Reading a directory returns null when deployed on the apache tomcat 7.0 server -


i'm trying read folder on network , retrieve list of txt files. when testing locally in eclipse, works fine, whenever deploy on apache tomcat 7 server returns null.

it doesn't seem access right problem since server has access folder i'm trying browse. i'm not sure going wrong there, setting on server need change or else?

private list<file> readdirectory() {     file test = new file(envmap.get(database));     list<file> files = new arraylist<file>();     try {         files = filelisting.getfilelisting(test);     } catch (filenotfoundexception e) {         // todo auto-generated catch block         e.printstacktrace();     }     list<file> txtfiles = new arraylist<file>();     if (files != null) {         (file file : files) {             if (file.isfile() && file.getname().endswith(".txt")) {                 txtfiles.add(file);             }         }     }     return txtfiles; } 

i used http://www.javapractices.com/topic/topicaction.do?id=68 filelisting.getfilelisting

after double checking turns out i'm getting filenotfoundexception: directory not exist. directory exists , server has access rights on it, i'm not sure of do.

files cannot null. code uses

static private list<file> getfilelistingnosort(file astartingdir) throws filenotfoundexception {     list<file> result = new arraylist<file>();     file[] filesanddirs = astartingdir.listfiles(); // may return null     list<file> filesdirs = arrays.aslist(filesanddirs); // throw npe     for(file file : filesdirs) {         result.add(file);          if (!file.isfile()) {             //must directory                            list<file> deeperlist = getfilelistingnosort(file);             result.addall(deeperlist);         }     }     return result; } 

are sure showing right code?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -