You could do it like that:
File folder = new File("your/path"); File[] listOfFiles = folder.listFiles(); if(listOfFiles != null) { for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { System.out.println("File " + listOfFiles[i].getName()); } else if (listOfFiles[i].isDirectory()) { System.out.println("Directory " + listOfFiles[i].getName()); } } } Do you want to only get JPEG files or all files?