Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.Collection; public class Main { public static Collection<String> getXmlFilenames(String path) throws NullPointerException { Collection<String> results = new ArrayList<>(); File folder = new File(path); // We will grab all XML files from the target directory. File[] listOfFiles = folder.listFiles(); if (listOfFiles != null) { String file; for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { file = listOfFiles[i].getAbsolutePath(); if (file.endsWith(".xml") || file.endsWith(".xml")) { results.add(file); } } } } return results; } }