/** * Identifies the group pattern from a given filename and directory. * * @param name The file basename to use as a template for the match. * @param dir The directory in which to search for matching files. * @return the identified pattern. */ public static String findPattern(String name, String dir) { if (dir == null) dir = ""; // current directory else if (!dir.equals("") && !dir.endsWith(File.separator)) { dir += File.separator; } Location dirFile = new Location(dir.equals("") ? "." : dir); // list files in the given directory Location[] f = dirFile.listFiles(); if (f == null) return null; String[] nameList = new String[f.length]; for (int i=0; i<nameList.length; i++) nameList[i] = f[i].getName(); return findPattern(name, dir, nameList); }
/** * Identifies the group pattern from a given filename and directory. * * @param name The file basename to use as a template for the match. * @param dir The directory in which to search for matching files. * @return the identified pattern. */ public static String findPattern(String name, String dir) { if (dir == null) dir = ""; // current directory else if (!dir.equals("") && !dir.endsWith(File.separator)) { dir += File.separator; } Location dirFile = new Location(dir.equals("") ? "." : dir); // list files in the given directory Location[] f = dirFile.listFiles(); if (f == null) return null; String[] nameList = new String[f.length]; for (int i=0; i<nameList.length; i++) nameList[i] = f[i].getName(); return findPattern(name, dir, nameList); }
/** Recursively set delete-on-exit for a directory tree. */ private void deleteTemporaryDirectoryOnExit(Location directoryRoot) { directoryRoot.deleteOnExit(); Location[] children = directoryRoot.listFiles(); if (children != null) { for (Location child : children) { if (child.isDirectory()) { deleteTemporaryDirectoryOnExit(child); } else { child.deleteOnExit(); } } } }
for (Location f: firstTiff.getParentFile().listFiles()) { names.add(f.getName());
for (Location f: firstTiff.getParentFile().listFiles()) { names.add(f.getName());