File类在指定目录下寻找特定格式的文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_40567229/article/details/86020286
class hello {
	public static void main(String[] args) throws ParseException {
		File dir = new File("C:\\Users\\Lee\\Pictures\\Saved Pictures");
		String arr[] = dir.list();
		for (String string : arr) {
			if(string.endsWith(".jpg"))
				System.out.println(string);
		}
	}

运行结果:

猜你喜欢

转载自blog.csdn.net/weixin_40567229/article/details/86020286