/** * Filters the files contained in a directory. */ public static String[] lsFiles(String directory, FilenameFilter filter) throws IOException { File dir = new File(directory); ArrayList<String> files = new ArrayList<>(); for (File filepath : dir.listFiles(filter)) { if (isFile(filepath.getAbsolutePath())) files.add(filepath.getAbsolutePath()); } return files.toArray(new String[files.size()]); }
/** * Filters the files contained in a directory. */ public static String[] lsFiles(String directory, FilenameFilter filter) throws IOException { File dir = new File(directory); ArrayList<String> files = new ArrayList<>(); for (File filepath : dir.listFiles(filter)) { if (isFile(filepath.getAbsolutePath())) files.add(filepath.getAbsolutePath()); } return files.toArray(new String[files.size()]); }
private List<String> getFiles(String dataDir) { List<String> files = new ArrayList<>(); FilenameFilter xmlFilter = (dir, name) -> (name.startsWith("pp-") && name.endsWith(".xml") && IOUtils .isFile(dir.getAbsolutePath() + File.separator + name)); String[] xmlFiles = (new File(dataDir)).list(xmlFilter); assert xmlFiles != null; for (String fileName : xmlFiles) { String rawFileName = IOUtils.stripFileExtension(fileName); files.add(rawFileName); } return files; } }
/** * Delete a file * * @return true only if the delete was successful */ public static boolean rm(String file) throws IOException { if (!exists(file)) return false; if (!isFile(file)) throw new IOException(file + " is not a file!"); return (new File(file)).delete(); }
private List<String> getFiles(String dataDir) { List<String> files = new ArrayList<>(); FilenameFilter xmlFilter = (dir, name) -> (name.startsWith("pp-") && name.endsWith(".xml") && IOUtils .isFile(dir.getAbsolutePath() + File.separator + name)); String[] xmlFiles = (new File(dataDir)).list(xmlFilter); assert xmlFiles != null; for (String fileName : xmlFiles) { String rawFileName = IOUtils.stripFileExtension(fileName); files.add(rawFileName); } return files; } }
/** * Delete a file * * @return true only if the delete was successful */ public static boolean rm(String file) throws IOException { if (!exists(file)) return false; if (!isFile(file)) throw new IOException(file + " is not a file!"); return (new File(file)).delete(); }
/** * Filters the files contained in a directory or in its subdirectory structure. Returns all * files (not directories) that pass the filter. */ public static String[] lsFilesRecursive(String directory, FilenameFilter filter) throws IOException { File dir = new File(directory); ArrayList<String> files = new ArrayList<>(); for (File filepath : dir.listFiles(filter)) { if (isFile(filepath.getAbsolutePath())) files.add(filepath.getAbsolutePath()); else if (isDirectory(filepath.getAbsolutePath())) files.addAll(Arrays.asList(lsFilesRecursive(filepath.getAbsolutePath(), filter))); } return files.toArray(new String[files.size()]); }
/** * Filters the files contained in a directory or in its subdirectory structure. Returns all * files (not directories) that pass the filter. */ public static String[] lsFilesRecursive(String directory, FilenameFilter filter) throws IOException { File dir = new File(directory); ArrayList<String> files = new ArrayList<>(); for (File filepath : dir.listFiles(filter)) { if (isFile(filepath.getAbsolutePath())) files.add(filepath.getAbsolutePath()); else if (isDirectory(filepath.getAbsolutePath())) files.addAll(Arrays.asList(lsFilesRecursive(filepath.getAbsolutePath(), filter))); } return files.toArray(new String[files.size()]); }
/** * A table is built from either a given source corpus file or source corpus directory by * counting the number of times that each suffix-POS association in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }
/** * A table is built from either a given source corpus file or source corpus directory by simply * counting the number of times that each form-POS association appear in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }
/** * A table is built from either a given source corpus file or source corpus directory by simply * counting the number of times that each form-POS association appear in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }
/** * A table is built from either a given source corpus file or source corpus directory by * counting the number of times that each suffix-POS association in a source corpus. * * @param home file name or directory name of the source corpus * @throws Exception **/ public void buildTable(String home) throws Exception { if (IOUtils.isFile(home)) this.buildTableHelper(home); else if (IOUtils.isDirectory(home)) { String[] files = IOUtils.lsFiles(home); for (String file : files) { // logger.info(file); this.buildTableHelper(home + "\\" + file); } } }