Java Code Examples for org.apache.commons.io.filefilter.NotFileFilter

The following examples show how to use org.apache.commons.io.filefilter.NotFileFilter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> getTestParameters() {

  FileFilter ff = new NotFileFilter(new SuffixFileFilter(".cdl"));
  List<Object[]> result = new ArrayList<Object[]>(500);
  try {
    TestDir.actOnAllParameterized(TestDir.cdmUnitTestDir + "formats/netcdf3/", ff, result);
    TestDir.actOnAllParameterized(TestDir.cdmUnitTestDir + "formats/netcdf4/", ff, result);
  } catch (IOException e) {
    e.printStackTrace();
  }

  return result;
}
 
Example 2
public static Collection<File> getPomFiles( File repoPath )
{
    Collection<File> pomFiles = new ArrayList<File>();
    Collection<File> leafDirectories = getLeafDirectories( repoPath );
    for ( File leafDirectory : leafDirectories )
    {
        IOFileFilter fileFilter = new AndFileFilter( new WildcardFileFilter( "*.pom" ),
                                           new NotFileFilter( new SuffixFileFilter( "sha1" ) ) );
        pomFiles.addAll( FileUtils.listFiles( leafDirectory, fileFilter, null ) );
    }
    return pomFiles;
}
 
Example 3
Source Project: repositoryminer   Source File: RMFileUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves all the sub directories from a root directory.
 * 
 * @param path
 *            the root path.
 * @return the sub directories.
 */
public static List<String> getAllDirsAsString(String path) {
	List<File> dirs = (List<File>) FileUtils.listFilesAndDirs(new File(path), new NotFileFilter(TrueFileFilter.INSTANCE),
			DirectoryFileFilter.DIRECTORY);
	List<String> dirsNames = new ArrayList<>();
	
	for (File f : dirs) {
		dirsNames.add(f.getAbsolutePath());
	}
	return dirsNames;
}
 
Example 4
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> getTestParameters() {
  String datadir = TestDir.cdmUnitTestDir;

  List<Object[]> result = new ArrayList<>(500);

  // result.add(new Object[]{datadir + "formats/netcdf4/tst/test_enum_type.nc", false});
  result.add(new Object[] {datadir + "conventions/atd-radar/rgg.20020411.000000.lel.ll.nc", false});
  result.add(new Object[] {datadir + "conventions/atd-radar/SPOL_3Volumes.nc", false});
  result.add(new Object[] {datadir + "conventions/awips/19981109_1200.nc", false});
  result.add(new Object[] {datadir + "conventions/cf/ccsm2.nc", false}); //
  result.add(new Object[] {datadir + "conventions/coards/cldc.mean.nc", false});
  result.add(new Object[] {datadir + "conventions/csm/o3monthly.nc", false});
  result.add(new Object[] {datadir + "conventions/gdv/OceanDJF.nc", false});
  result.add(new Object[] {datadir + "conventions/gief/coamps.wind_uv.nc", false});
  result.add(new Object[] {datadir + "conventions/mars/temp_air_01082000.nc", true});
  result.add(new Object[] {datadir + "conventions/nuwg/eta.nc", false});
  result.add(new Object[] {datadir + "conventions/nuwg/ocean.nc", true});
  result.add(new Object[] {datadir + "conventions/wrf/wrfout_v2_Lambert.nc", false});

  result.add(new Object[] {datadir + "formats/grib2/eta2.wmo", false}); //
  result.add(new Object[] {datadir + "formats/grib2/ndfd.wmo", false}); //

  result.add(new Object[] {datadir + "formats/gini/n0r_20041013_1852-compress", false}); //
  result.add(new Object[] {datadir + "formats/gini/ntp_20041206_2154", true}); //
  result.add(new Object[] {datadir + "formats/dmsp/F14200307192230.n.OIS", false}); //

  result.add(new Object[] {datadir + "formats/nexrad/level2/6500KHGX20000610_000110", false});
  result.add(new Object[] {datadir + "formats/nexrad/level2/Level2_KYUX_20060527_2335.ar2v", true});

  result.add(new Object[] {datadir + "conventions/nuwg/ocean.nc", true});

  // try everything from these directories
  try {
    addFromScan(result, TestDir.cdmUnitTestDir + "formats/netcdf4/",
        new NotFileFilter(new SuffixFileFilter(new String[] {".cdl", ".nc5", ".gbx9"})), false);
  } catch (IOException e) {
    e.printStackTrace();
  }

  return result;
}
 
Example 5
Source Project: torrssen2   Source File: CommonUtils.java    License: MIT License 4 votes vote down vote up
public static List<String> removeDirectory(String path, String outer, SettingRepository settingRepository) {
    String[] exts = {};
    Optional<Setting> exceptExtSetting = settingRepository.findByKey("EXCEPT_EXT");
    if(exceptExtSetting.isPresent()) {
        exts = StringUtils.split(StringUtils.lowerCase(exceptExtSetting.get().getValue()), ",");
    }

    Optional<Setting> delDirSetting = settingRepository.findByKey("DEL_DIR");
    
    if (delDirSetting.isPresent()) {
        if(Boolean.parseBoolean(delDirSetting.get().getValue())) {
            File file = new File(path, outer);
            if (file.isDirectory()) {
                Collection<File> subFiles;
                if(exts != null) {
                    NotFileFilter fileFilter = new NotFileFilter(new SuffixFileFilter(exts)); 
                    subFiles = FileUtils.listFiles(new File(path, outer), fileFilter, TrueFileFilter.INSTANCE);
                } else {
                    subFiles = FileUtils.listFiles(new File(path, outer), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
                }
                
                List<String> ret = new ArrayList<>();

                try {
                    for(File subFile: subFiles) {
                        log.debug(subFile.getPath() + ":" + subFile.getName());
                        File remove = new File(path, subFile.getName());
                        if (remove.isFile()) {
                            FileUtils.forceDelete(remove);
                        }
                        FileUtils.moveFileToDirectory(subFile, new File(path), true);
                        ret.add(subFile.getName());
                    }
                    FileUtils.forceDelete(new File(path, outer));
                } catch (IOException e) {
                    log.error(e.getMessage());
                }

                return ret;
            } 
        }
    }

    return null;
}
 
Example 6
Source Project: hsac-fitnesse-fixtures   Source File: HsacFitNesseRunner.java    License: Apache License 2.0 4 votes vote down vote up
protected FileFilter getFileSectionCopyFilter(Class<?> suiteClass) {
    List<String> excludes = getFileSectionCopyExcludes(suiteClass);
    List<IOFileFilter> excludeFilters = new ArrayList<>(excludes.size());
    excludes.forEach(x -> excludeFilters.add(new WildcardFileFilter(x)));
    return new NotFileFilter(new OrFileFilter(excludeFilters));
}
 
Example 7
Source Project: repositoryminer   Source File: RMFileUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves all the sub directories from a root directory.
 * 
 * @param path
 *            the root path.
 * @return the sub directories.
 */
public static List<File> getAllDirs(String path) {
	return (List<File>) FileUtils.listFilesAndDirs(new File(path), new NotFileFilter(TrueFileFilter.INSTANCE),
			DirectoryFileFilter.DIRECTORY);
}