import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.PathMatcher; public class GlobExample { public static void main(String[] args) { FileSystem fileSystem = FileSystems.getDefault(); PathMatcher pathMatcher = fileSystem.getPathMatcher("glob:/path/to/files/*.txt"); Path path1 = fileSystem.getPath("/path/to/files/file1.txt"); Path path2 = fileSystem.getPath("/path/to/files/file2.xml"); } } properties pattern=glob:/path/to/files/*.txt import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class ConfigExample { public static void main(String[] args) { Properties properties = new Properties(); try (FileInputStream fis = new FileInputStream("config.properties")) { properties.load(fis); String pattern = properties.getProperty("pattern"); System.out.println("Pattern: " + pattern); } catch (IOException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文