0

I need to sort files based on their name and extension. I use apache commons-io RegexFileFilter for that. The filename pattern is something like this: "filename.xml.20130101200" or "filename.xml.20130101200.inprog", where numbers are simple timestamp.

FileFilter regexFilter = new RegexFileFilter( ".*\\d{12}|.*inprog" );
File[] suitableFiles = dir.listFiles( regexFilter );

If this directory that contains those files is in my home dir "/home/user/files" then everything works fine when running with jboss. But when I change folder to "/tmp/files/" then filter will find files with ".inprog" extension. When i log the number of files in dir, it shows correct amount. I wrote simple main program for testing and everything works fine there, even if files are in /tmp/files. Jboss lives in my home folder.

What could be the problem?

jyriand
  • 2,434
  • 3
  • 23
  • 28

1 Answers1

0

Problem was in regex. Regex string was taken from oracle db table. When I changed it to ".*\d{12}|.inprog", removing one backslash, it started to work. Also ".[0-9]{12}|.*inprog" works correctly

jyriand
  • 2,434
  • 3
  • 23
  • 28