[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
How to use FileManager.getFilesOfDirectoryByPattern  XML
Forum Index -> Development
Author Message
heyl

Power User

Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline

Hello,

can anybody give me an example of how to use
Code:
Filemanager.getFilesOfDirectoryByPattern(directory, pattern, extension)

I can't get it working and I found nothing in the docs.

Frauke
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

...a quite special method...:
Code:
     public static List<String> getFilesOfDirectoryByPattern(String directoryName, 
                                                             String pattern,
                                                             String extension)
     {
         List<String> result = new ArrayList<String>();
         List<File> files = getFilesOfDirectory(directoryName);
         for (File file: files)
         {
             String fileAbsoluteName = file.getAbsolutePath();
             String fileSimpleName = file.getName();
             if (extension != null && fileSimpleName.endsWith(extension) == false) 
                 continue;
             if (fileSimpleName.startsWith(pattern + "."))
                 result.add(fileAbsoluteName);
         }
         return result;
     }
 


Regards, Björn

Björn Müller, CaptainCasa GmbH
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

...we internally use it for the followin situations:

a user can define config files in the way:

system.xml
system.abc.xml
system.cde.xml

So that not all information is shared within ONE and the same file. Please compare to web.xml: here everyone has to merge into one file... it would be nice to have

web.xml
web.captaincasa.xml
web.vps.xml

and all things are merged internally. OF COURSE THIS DOES NOT WORK... this is just an example.

The method "read by pattern" is one that returns the corresponding files.

Regards, Björn

Björn Müller, CaptainCasa GmbH
heyl

Power User

Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline

Ok, let's use the normal one
Code:
FileManager.getFilesOfDirectory(directory)


Frauke
heyl

Power User

Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline

Still I have a problem with it, it does not find any files.
I call
Code:
FileManager.getFilesOfDirectory("/forms")

with the directory structure as shown in the sceenshot.

What is the correct root directory?

Frauke
 Filename formsdir.JPG [Disk] Download
 Description
 Filesize 12 Kbytes
 Downloaded:  408 time(s)

 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team