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);
}
}
运行结果: