2.3.1 search for files in projects and 2.3.1 search for files in projects
Demo:
Import java. io. IOException; import java. nio. file. directoryStream; import java. nio. file. files; import java. nio. file. path; import java. nio. file. paths;/** search for files in the directory: filter all files in the dir project using pattern matching. properties file; * @ author jinxing * @ DirectoryStream <Path> stream = Files. newDirectoryStream (dir ,"*. properties ") * The pattern matching used in the filter stream is called glob pattern matching --*. properties */public class PathFindGlob {public static void main (String [] args) {// The pre-prepared directory and the three files in it: log4j. xml, signed URL. properties, weixinjsapi. properties Path dir = Paths. get ("/Users/jinxing/Documents/pathtest/path1"); try (DirectoryStream <Path> stream = Files. newDirectoryStream (dir ,"*. properties ") {for (Path entry: stream) {System. out. println (entry. getFileName () ;}} catch (IOException e) {System. out. println (e. getMessage ());}}}
Ran As Java Application:
shortUrl.propertiesweixinjsapi.properties