Need to list files under a specific folder in a main folder using java -


i need files under "completed jobs" folder , main level "jobs" , want filter files under "completed jobs" folder

  http://192.168.0.19/svn/cadgraf/branch/jobs      user1     active     completedobs   user2     active     completedjobs   user3     active     completedjobs 

i used find files in job folder:

   public file[] listf(string directoryname) throws ioexception {     file directory = new file(directoryname);     file[] flist = directory.listfiles();     (file file : flist) {         try {             if (file.isfile() && file.getname().contains(".xml")) {                 filenamelist.addelement(file.getname());                 files.add(file);                 l_storieslist.setmodel(filenamelist);              } else if (file.isdirectory()) {                 listf(file.getabsolutepath());             }         } catch (exception ex) {             ex.getstacktrace();         }     }     return flist; } 

see documentation file.listfiles.

note listfiles give both files , folders, since folders regarded different kind of files. if want files, not folders, use isfile() method.

to files in folder , subfolders, can (1) add folders list , files list (and removing folder folder list after looked through it), , (2) every folder until folder list empty.

you can give file filter listfiles method, , create filter lets through files , 1 filter lets through folders. however, such simple problem might more confusing useful.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -