Java tutorial
//package com.java2s; import java.io.File; import java.util.TreeMap; import java.util.Vector; import java.util.regex.Pattern; public class Main { private static TreeMap<String, String> pathMap; public static void U7ListFiles(String mask, Vector<String> filelist) { mask = getSystemPath(mask); char sep = '/'; int split = mask.lastIndexOf(sep); String dir, nameMask; if (split == -1) { dir = "."; nameMask = mask; } else { dir = mask.substring(0, split); nameMask = mask.substring(split + 1); } File folder = new File(dir); File[] listOfFiles = folder.listFiles(); Pattern pattern = Pattern.compile(nameMask); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { String fname = listOfFiles[i].getName(); if (pattern.matcher(fname).matches()) filelist.add(dir + sep + fname); } } } public static String getSystemPath(String path) { String newPath; int pos, pos2; pos = path.indexOf('>'); pos2 = path.indexOf('<'); // If there is no separator, return the path as is if (pos == -1 || pos2 != 0) { newPath = path; } else { pos += 1; // See if we can translate this prefix String syspath = path.substring(0, pos); if (isSystemPathDefined(syspath)) { String newPrefix = pathMap.get(syspath); newPath = newPrefix + path.substring(pos); } else { newPath = path; } } return newPath; } public static boolean isSystemPathDefined(String path) { return pathMap != null && pathMap.containsKey(path); } }