[
https://issues.apache.org/jira/browse/IO-281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089091#comment-13089091
]
Dean Schulze commented on IO-281:
---------------------------------
This looks like unexpected behavior from the Java File class. If I create a
File object for a file that exists in the current directory the various File
methods all return either null or a path that ends with the file name instead
of the directory name.
I've resorted to manually parsing off the file name from the end of the
absolute path.
http://stackoverflow.com/questions/7153729/java-cant-get-the-path-of-a-file-that-exists-in-the-current-directory/7154296#7154296
This can probably be closed out.
> WildcardFileFilter fails for wild card pattern with a '*' in it
> ---------------------------------------------------------------
>
> Key: IO-281
> URL: https://issues.apache.org/jira/browse/IO-281
> Project: Commons IO
> Issue Type: Bug
> Components: Filters
> Affects Versions: 1.3.2
> Environment: Windows XP
> Reporter: Dean Schulze
> Priority: Blocker
>
> The code below reports no files found when there is a file matching the wild
> card pattern. If I enter this command in a DOS windows in the same directory
> it finds the file so the wild card pattern is correct as far as DOS is
> concerned:
> {code}
> C:\dean\clipper\src\metadata.mail>dir 320620110821433-*.RWD
>
> Directory of C:\dean\clipper\src\metadata.mail
> 08/22/2011 12:36 PM 9,728 320620110821433-1.RWD
> 1 File(s) 9,728 bytes
> 0 Dir(s) 50,033,049,600 bytes free
> {code}
> This code should work according to the docs but it reports no file found:
> {code}
> void testFileNameFilter() throws IOException {
>
> String fileNamePrefix = "320620110821433";
> File f = new File(fileNamePrefix + ".rwd");
> String filterString = fileNamePrefix + "-*.RWD";
> FileFilter filter = new WildcardFileFilter(filterString,
> IOCase.SYSTEM);
> File dir = f.getCanonicalFile();
> File[] existingFiles = dir.listFiles(filter);
>
> if (existingFiles != null)
> for (File f2 : existingFiles)
> System.out.println(f2.getName());
> else
> System.out.println("No files found for" + filterString);
> }
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira