List of usage examples for org.apache.commons.io.filefilter HiddenFileFilter VISIBLE
IOFileFilter VISIBLE
To view the source code for org.apache.commons.io.filefilter HiddenFileFilter VISIBLE.
Click Source Link
From source file:com.soebes.maven.plugins.iterator.AbstractIteratorMojo.java
public List<String> getFolders() throws MojoExecutionException { IOFileFilter folders = FileFilterUtils.and(HiddenFileFilter.VISIBLE, DirectoryFileFilter.DIRECTORY); IOFileFilter makeSVNAware = FileFilterUtils.makeSVNAware(folders); IOFileFilter makeCVSAware = FileFilterUtils.makeCVSAware(makeSVNAware); String[] list = folder.list(makeCVSAware); if (list == null) { throw new MojoExecutionException("The specified folder doesn't exist: " + folder); }/* w w w . java2 s .co m*/ List<File> listOfDirectories = new ArrayList<File>(); for (String item : list) { listOfDirectories.add(new File(folder, item)); } Collections.sort(listOfDirectories, convertSortOrder()); List<String> resultList = new ArrayList<String>(); for (File file : listOfDirectories) { resultList.add(file.getName()); } return resultList; }
From source file:admincommands.Reload.java
@SuppressWarnings("unchecked") private Collection<File> listFiles(File root, boolean recursive) { IOFileFilter dirFilter = recursive ? makeSVNAware(HiddenFileFilter.VISIBLE) : null; return FileUtils.listFiles(root, andFileFilter(andFileFilter(notFileFilter(prefixFileFilter("new")), suffixFileFilter(".xml")), HiddenFileFilter.VISIBLE), dirFilter);/*from w ww .j a v a2 s. c om*/ }
From source file:com.totsp.mavenplugin.gwt.scripting.ScriptWriterWindows.java
/** * Write test scripts.//from www . j av a 2 s. c om */ public void writeTestScripts(AbstractGWTMojo mojo) throws MojoExecutionException { // get extras String extra = (mojo.getExtraJvmArgs() != null) ? mojo.getExtraJvmArgs() : ""; String testExtra = mojo.getExtraTestArgs() != null ? mojo.getExtraTestArgs() : ""; // make sure output dir is present File outputDir = new File(mojo.getBuildDir(), "gwtTest"); outputDir.mkdirs(); outputDir.mkdir(); // for each test compile source root, build a test script List<String> testCompileRoots = mojo.getProject().getTestCompileSourceRoots(); for (String currRoot : testCompileRoots) { Collection<File> coll = FileUtils.listFiles(new File(currRoot), new WildcardFileFilter(mojo.getTestFilter()), HiddenFileFilter.VISIBLE); for (File currFile : coll) { String testName = currFile.toString(); mojo.getLog().debug(("gwtTest test match found (after filter applied) - " + testName)); // parse off the extension if (testName.lastIndexOf('.') > testName.lastIndexOf(File.separatorChar)) { testName = testName.substring(0, testName.lastIndexOf('.')); } if (testName.startsWith(currRoot)) { testName = testName.substring(currRoot.length()); } if (testName.startsWith(File.separator)) { testName = testName.substring(1); } testName = StringUtils.replace(testName, File.separatorChar, '.'); mojo.getLog().debug("testName after parsing - " + testName); // start script inside gwtTest output dir, and name it with test class name File file = new File(mojo.getBuildDir() + File.separator + "gwtTest", "gwtTest-" + testName + ".cmd"); PrintWriter writer = this.getPrintWriterWithClasspath(mojo, file, DependencyScope.TEST); // build Java command writer.print("\"" + mojo.getJavaCommand() + "\" "); if (extra.length() > 0) { writer.print(" " + extra + " "); } if (testExtra.length() > 0) { writer.print(" " + testExtra + " "); } writer.print("-cp %CLASSPATH% "); writer.print("-Dcatalina.base=\"" + mojo.getTomcat().getAbsolutePath() + "\" "); writer.print("junit.textui.TestRunner "); writer.print(testName); // write script out writer.flush(); writer.close(); } } }
From source file:fr.ericlab.sondy.core.DataManipulation.java
public ObservableList<String> getAvailableStopwords(AppVariables appVariables) { ObservableList<String> stopwordsList = FXCollections.observableArrayList(); File dir = new File(appVariables.configuration.getWorkspace() + "/stopwords/"); boolean error = false; if (!dir.exists()) { try {//from w w w. j ava2 s .c om dir.mkdirs(); InputStream twitterInputStream = DataManipulation.class .getResource("/resources/stopwords/twitter(en)").openStream(); InputStream commonInputStream = DataManipulation.class .getResource("/resources/stopwords/common(en)").openStream(); OutputStream twitterOutStream = new FileOutputStream( new File(appVariables.configuration.getWorkspace() + "/stopwords/twitter(en)")); OutputStream commonOutStream = new FileOutputStream( new File(appVariables.configuration.getWorkspace() + "/stopwords/common(en)")); IOUtils.copy(twitterInputStream, twitterOutStream); IOUtils.copy(commonInputStream, commonOutStream); IOUtils.closeQuietly(twitterInputStream); IOUtils.closeQuietly(twitterOutStream); IOUtils.closeQuietly(commonInputStream); IOUtils.closeQuietly(commonOutStream); } catch (IOException ex) { Logger.getLogger(DataManipulation.class.getName()).log(Level.SEVERE, null, ex); error = true; appVariables.addLogEntry("[global] can't access workspace"); } } if (!error) { List<File> files = (List<File>) FileUtils.listFiles(dir, HiddenFileFilter.VISIBLE, null); for (File file : files) { stopwordsList.add("stopwords: " + file.getName()); } } return stopwordsList; }
From source file:com.totsp.mavenplugin.gwt.scripting.ScriptWriterUnix.java
/** * Write test scripts./*from w w w .j a v a2 s.c o m*/ */ public void writeTestScripts(AbstractGWTMojo mojo) throws MojoExecutionException { // get extras String extra = (mojo.getExtraJvmArgs() != null) ? mojo.getExtraJvmArgs() : ""; if (AbstractGWTMojo.OS_NAME.startsWith("mac") && (extra.indexOf("-XstartOnFirstThread") == -1)) { extra = "-XstartOnFirstThread " + extra; } String testExtra = mojo.getExtraTestArgs() != null ? mojo.getExtraTestArgs() : ""; // make sure output dir is present File outputDir = new File(mojo.getBuildDir(), "gwtTest"); outputDir.mkdirs(); outputDir.mkdir(); // for each test compile source root, build a test script List<String> testCompileRoots = mojo.getProject().getTestCompileSourceRoots(); for (String currRoot : testCompileRoots) { // TODO better file filter here Collection<File> coll = FileUtils.listFiles(new File(currRoot), new WildcardFileFilter(mojo.getTestFilter()), HiddenFileFilter.VISIBLE); for (File currFile : coll) { String testName = currFile.toString(); mojo.getLog().debug(("gwtTest test match found (after filter applied) - " + testName)); // parse off the extension if (testName.lastIndexOf('.') > testName.lastIndexOf(File.separatorChar)) { testName = testName.substring(0, testName.lastIndexOf('.')); } if (testName.startsWith(currRoot)) { testName = testName.substring(currRoot.length()); } if (testName.startsWith(File.separator)) { testName = testName.substring(1); } testName = StringUtils.replace(testName, File.separatorChar, '.'); mojo.getLog().debug("testName after parsing - " + testName); // start script inside gwtTest output dir, and name it with test class name File file = new File(mojo.getBuildDir() + File.separator + "gwtTest", "gwtTest-" + testName + ".sh"); PrintWriter writer = this.getPrintWriterWithClasspath(mojo, file, DependencyScope.TEST); // build Java command writer.print("\"" + mojo.getJavaCommand() + "\" "); if (extra.length() > 0) { writer.print(" " + extra + " "); } if (testExtra.length() > 0) { writer.print(" " + testExtra + " "); } writer.print("-cp \"$CP\" "); writer.print("-Dcatalina.base=\"" + mojo.getTomcat().getAbsolutePath() + "\" "); writer.print("junit.textui.TestRunner "); writer.print(testName); // write script out writer.flush(); writer.close(); this.chmodUnixFile(file); } } }
From source file:com.aionengine.gameserver.dataholders.loadingutils.XmlMerger.java
@SuppressWarnings("unchecked") private static Collection<File> listFiles(File root, boolean recursive) { IOFileFilter dirFilter = recursive ? makeSVNAware(HiddenFileFilter.VISIBLE) : null; return FileUtils.listFiles(root, andFileFilter(andFileFilter(notFileFilter(prefixFileFilter("new")), suffixFileFilter(".xml")), HiddenFileFilter.VISIBLE), dirFilter);//from w w w . j a v a 2 s. c om }
From source file:com.aionemu.gameserver.dataholders.loadingutils.XmlMerger.java
@SuppressWarnings("deprecation") private static Collection<File> listFiles(File root, boolean recursive) { IOFileFilter dirFilter = recursive ? makeSVNAware(HiddenFileFilter.VISIBLE) : null; return FileUtils.listFiles(root, andFileFilter(andFileFilter(notFileFilter(prefixFileFilter("new")), suffixFileFilter(".xml")), HiddenFileFilter.VISIBLE), dirFilter);/*ww w . j a v a 2 s. c o m*/ }
From source file:com.totsp.mavenplugin.gwt.scripting.ScriptWriterUnix16.java
/** * Write test scripts./*from w w w . j a v a 2s .c om*/ */ public void writeTestScripts(AbstractGWTMojo mojo) throws MojoExecutionException { // get extras String extra = (mojo.getExtraJvmArgs() != null) ? mojo.getExtraJvmArgs() : ""; if (AbstractGWTMojo.OS_NAME.startsWith("mac") && (extra.indexOf("-XstartOnFirstThread") == -1)) { extra = "-XstartOnFirstThread " + extra; } String testExtra = (mojo.getExtraTestArgs() != null) ? mojo.getExtraTestArgs() : ""; // make sure output dir is present File outputDir = new File(mojo.getBuildDir(), "gwtTest"); outputDir.mkdirs(); outputDir.mkdir(); // for each test compile source root, build a test script List<String> testCompileRoots = mojo.getProject().getTestCompileSourceRoots(); for (String currRoot : testCompileRoots) { // TODO better file filter here Collection<File> coll = FileUtils.listFiles(new File(currRoot), new WildcardFileFilter(mojo.getTestFilter()), HiddenFileFilter.VISIBLE); for (File currFile : coll) { String testName = currFile.toString(); mojo.getLog().debug(("gwtTest test match found (after filter applied) - " + testName)); // parse off the extension if (testName.lastIndexOf('.') > testName.lastIndexOf(File.separatorChar)) { testName = testName.substring(0, testName.lastIndexOf('.')); } if (testName.startsWith(currRoot)) { testName = testName.substring(currRoot.length()); } if (testName.startsWith(File.separator)) { testName = testName.substring(1); } testName = StringUtils.replace(testName, File.separatorChar, '.'); mojo.getLog().debug("testName after parsing - " + testName); // start script inside gwtTest output dir, and name it with test class name File file = new File(mojo.getBuildDir() + File.separator + "gwtTest", "gwtTest-" + testName + ".sh"); PrintWriter writer = this.getPrintWriterWithClasspath(mojo, file, DependencyScope.TEST); // build Java command writer.print("\"" + mojo.getJavaCommand() + "\" "); if (extra.length() > 0) { writer.print(" " + extra + " "); } if (testExtra.length() > 0) { writer.print(" " + testExtra + " "); } writer.print(" -cp \"$CP\" "); writer.print("junit.textui.TestRunner "); writer.print(testName); // write script out writer.flush(); writer.close(); this.chmodUnixFile(file); } } }
From source file:com.aliyun.odps.local.common.WareHouse.java
/** * copy table schema and partition data from warehouse to target directory , * if partition not exists will download the partition data and table schema * from remote server/*from w w w.j av a2s .c o m*/ * * @param projectName * @param tableName * @param partSpec * if null will copy all partitions * @param readCols * if null will copy all columns * @param destDir * @return * @throws IOException * @throws OdpsException */ public boolean copyTable(String projectName, String tableName, PartitionSpec partSpec, String[] readCols, File destDir, int limitDownloadRecordCount, char inputColumnSeperator) { if (StringUtils.isBlank(projectName) || StringUtils.isBlank(tableName) || destDir == null) { return false; } TableInfo tableInfo = TableInfo.builder().projectName(projectName).tableName(tableName).partSpec(partSpec) .build(); LOG.info("Start to copy table: " + tableInfo + "-->" + destDir.getAbsolutePath()); boolean hasPartition = false; if (partSpec != null && !partSpec.isEmpty()) { hasPartition = true; } // if not exist table, then download from odps server if (hasPartition && !existsPartition(projectName, tableName, partSpec)) { DownloadUtils.downloadTableSchemeAndData(getOdps(), tableInfo, limitDownloadRecordCount, inputColumnSeperator); } else if (!existsTable(projectName, tableName)) { DownloadUtils.downloadTableSchemeAndData(getOdps(), tableInfo, limitDownloadRecordCount, inputColumnSeperator); } File whTableDir = getTableDir(projectName, tableName); // copy schema file File schemaFile = new File(whTableDir, Constants.SCHEMA_FILE); if (!schemaFile.exists()) { throw new RuntimeException( "Schema file of table " + projectName + "." + tableName + " not exists in warehouse."); } if (!destDir.exists()) { destDir.mkdirs(); } // copy table schema file try { FileUtils.copyFileToDirectory(schemaFile, destDir); } catch (IOException e) { throw new RuntimeException("Copy schema file of table " + tableInfo + " failed!" + e.getMessage()); } // copy partition data files TableMeta tableMeta = getTableMeta(projectName, tableName); List<Integer> indexes = LocalRunUtils.genReadColsIndexes(tableMeta, readCols); if (hasPartition) { final Collection<File> dataFiles = FileUtils.listFiles(whTableDir, HiddenFileFilter.VISIBLE, HiddenFileFilter.VISIBLE); for (File dataFile : dataFiles) { if (dataFile.getName().equals(Constants.SCHEMA_FILE)) { continue; } String parentDir = dataFile.getParentFile().getAbsolutePath(); String partPath = parentDir.substring(whTableDir.getAbsolutePath().length(), parentDir.length()); PartitionSpec ps = PartitionUtils.convert(partPath); if (PartitionUtils.isEqual(ps, partSpec)) { File destPartitionDir = new File(destDir, PartitionUtils.toString(ps)); destPartitionDir.mkdirs(); try { copyDataFiles(dataFile.getParentFile(), indexes, destPartitionDir, inputColumnSeperator); } catch (IOException e) { throw new RuntimeException( "Copy data file of table " + tableInfo + " failed!" + e.getMessage()); } } } } else { try { copyDataFiles(whTableDir, indexes, destDir, inputColumnSeperator); } catch (IOException e) { throw new RuntimeException("Copy data file of table " + tableInfo + " failed!" + e.getMessage()); } } LOG.info("Finished copy table: " + tableInfo + "-->" + destDir.getAbsolutePath()); return true; }
From source file:com.aliyun.odps.local.common.WareHouse.java
public Map<PartitionSpec, File> getPartitionToPathMap(String projName, String tblName) { File tableDir = getTableDir(projName, tblName); TableMeta tableMeta = SchemaUtils.readSchema(tableDir); Map<PartitionSpec, File> result = new HashMap<PartitionSpec, File>(); File dir = getTableDir(projName, tblName); final Collection<File> dataFiles = FileUtils.listFiles(dir, HiddenFileFilter.VISIBLE, HiddenFileFilter.VISIBLE);// ww w.j a v a 2 s.c o m List<File> emptyPatitions = LocalRunUtils.listEmptyDirectory(dir); dataFiles.addAll(emptyPatitions); for (File dataFile : dataFiles) { if (dataFile.getName().equals(Constants.SCHEMA_FILE)) { continue; } String partPath = null; if (dataFile.isFile()) { String parentDir = dataFile.getParentFile().getAbsolutePath(); partPath = parentDir.substring(dir.getAbsolutePath().length(), parentDir.length()); } else { // empty partition directory String parentDir = dataFile.getAbsolutePath(); partPath = parentDir.substring(dir.getAbsolutePath().length(), parentDir.length()); } try { if (partPath.length() > 0) { PartitionSpec ps = PartitionUtils.convert(partPath); if (PartitionUtils.valid(tableMeta.getPartitions(), ps)) { result.put(ps, dataFile.getParentFile()); } } } catch (Exception ex) { // LOG.warn("ignore dir: " + parentDir + ", " + ex.getMessage()); } } return result; }