Java tutorial
//package com.java2s; import java.io.File; import java.util.Vector; public class Main { private static void addFiles(File root, Vector<String> files) { if (root == null) return; File[] listFiles = root.listFiles(); if (listFiles == null) return; for (File f : listFiles) { if (f.isDirectory()) addFiles(f, files); else if (f.getName().endsWith(".pfy")) files.add(f.getAbsolutePath()); } } }