Skip to main content
2 of 5
added 6 characters in body
RoflcoptrException
  • 52.3k
  • 35
  • 154
  • 200

For example for the C: directory you could do it like that:

File folder = new File("your/path"); File[] listOfFiles = folder.listFiles(); 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?

RoflcoptrException
  • 52.3k
  • 35
  • 154
  • 200