Author |
Message |
22/12/2010 11:58:56
|
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
|
|
|
22/12/2010 12:02:22
|
CaptainCasa
Power User
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 |
|
|
22/12/2010 12:06:20
|
CaptainCasa
Power User
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 |
|
|
22/12/2010 12:06:35
|
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
|
|
|
22/12/2010 12:54:52
|
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 |
Download
|
Description |
|
Filesize |
12 Kbytes
|
Downloaded: |
408 time(s) |
|
|
|
|