File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
src/main/java/io/github/benas/unixstream Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -136,21 +136,17 @@ static UnixStream<String> pwd() {
136
136
* Find files by name (recursively) in a given directory.
137
137
*
138
138
* @param directory the root directory
139
- * @param pattern the file name pattern with <a href="https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob">glob syntax</a>.
139
+ * @param pattern the file name pattern with <a href="https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob">glob syntax</a>.
140
140
* @return a new UnixStream with found files
141
+ * @throws IOException thrown if an error occurs during reading the file
141
142
*/
142
- static UnixStream <Path > find (final Path directory , final String pattern ) {
143
+ static UnixStream <Path > find (final Path directory , final String pattern ) throws IOException {
143
144
Objects .requireNonNull (directory , "The root directory must not be null" );
144
145
Objects .requireNonNull (pattern , "The file pattern must not be null" );
145
146
PathMatcher pathMatcher = FileSystems .getDefault ().getPathMatcher ("glob:" + pattern );
146
- try {
147
- return new UnixStreamImpl <>(walk (directory )
148
- .filter (path -> !isDirectory (path ))
149
- .filter (path -> pathMatcher .matches (path .getFileName ())));
150
-
151
- } catch (IOException e ) {
152
- throw new RuntimeException ("Unable to find files in directory " + directory );
153
- }
147
+ return new UnixStreamImpl <>(walk (directory )
148
+ .filter (path -> !isDirectory (path ))
149
+ .filter (path -> pathMatcher .matches (path .getFileName ())));
154
150
}
155
151
156
152
/**
You can’t perform that action at this time.
0 commit comments