在Windows OS上使用FileIO.match()。filepattern(“ pattern”)时遇到了一个真正的问题。每当我在模式参数中使用星号(即“ / c / temp / *。zip” /
)时,都会出现以下异常Caused by: java.nio.file.InvalidPathException: Illegal char <*> at index 7: c/temp/*.zip
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at java.nio.file.Paths.get(Paths.java:84)
at org.apache.beam.sdk.io.LocalFileSystem.matchOne(LocalFileSystem.java:219)
at org.apache.beam.sdk.io.LocalFileSystem.match(LocalFileSystem.java:89)
at org.apache.beam.sdk.io.FileSystems.match(FileSystems.java:123)
at org.apache.beam.sdk.io.FileSystems.match(FileSystems.java:145)
at org.apache.beam.sdk.io.FileSystems.match(FileSystems.java:157)
at org.apache.beam.sdk.io.FileIO$MatchAll$MatchFn.process(FileIO.java:632)
我已经通过调试源代码进行了一些研究。 https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/LocalFileSystem.java
在matchOne方法中,第217行尝试通过
创建FileFile file = Paths.get(spec).toFile();
失败。它永远不会到达第238行
final PathMatcher matcher =
java.nio.file.FileSystems.getDefault().getPathMatcher("glob:" + pathToMatch);
使用glob的地方。
是错误吗? 感谢您的帮助。