{{theTime}}

Search This Blog

Total Pageviews

How to filter the file names in a directory using Java.

 
public String[] filterFileNames() throws IOException
   String pattern = "Today";
   final Pattern p = Pattern.compile(pattern);
   FilenameFilter filter = new FilenameFilter() {
   public boolean accept(File fdir, String fname)
   {
       Matcher m = p.matcher(fname);
       return m.matches();
   }};
   File dirFile = new File( "directory path" );
   String[] filteredFiles = dirFile.list(filter); 
   return filteredFiles ;
}



No comments:

Windows 8.3 file naming setting is disabled for the product

To enable Windows 8.3 file naming setting use fsutil command Example:  c:\> fsutil 8dot3name set C: 0