當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectoryScanner.setBasedir方法代碼示例

本文整理匯總了Java中org.apache.tools.ant.DirectoryScanner.setBasedir方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryScanner.setBasedir方法的具體用法?Java DirectoryScanner.setBasedir怎麽用?Java DirectoryScanner.setBasedir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.tools.ant.DirectoryScanner的用法示例。


在下文中一共展示了DirectoryScanner.setBasedir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scanForFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private static void scanForFiles(Collection<File> destination, String pathAndMask) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setCaseSensitive(false);

    String pathPart = FilenameUtils.getFullPath(pathAndMask);
    if(StringUtils.isEmpty(pathPart))
    {
        scanner.setBasedir(Paths.get(".").toAbsolutePath().normalize().toFile());
        scanner.setIncludes(new String[]{pathAndMask});
    }
    else
    {
        scanner.setBasedir(new File(pathPart));
        scanner.setIncludes(new String[]{FilenameUtils.getName(pathAndMask)});
    }

    scanner.scan();
    for (String file : scanner.getIncludedFiles()) {
        destination.add(new File(scanner.getBasedir(),file));
    }
}
 
開發者ID:BigBrassBand,項目名稱:remittanceparse,代碼行數:22,代碼來源:Main.java

示例2: listFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public List<File> listFiles(final String mask) {
    try {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setIncludes(new String[]{mask});
        scanner.setBasedir(this.basedir.replace("\\", "/"));
        scanner.setCaseSensitive(false);
        scanner.scan();
        String[] files = scanner.getIncludedFiles();
        List<File> result = new ArrayList<>();
        for (String file : files) {
            result.add(
                    new SimpleFile(file,
                            FileUtils.readFileToByteArray(new java.io.File(basedir + "/" + file))));
        }
        return result;
    } catch (IOException exception) {
        throw new BootException(exception);
    }
}
 
開發者ID:sql-boot,項目名稱:sql-boot,代碼行數:21,代碼來源:LocalFileSystem.java

示例3: getClassFileInClasspath

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public static String[] getClassFileInClasspath()
{
  String classpath = System.getProperty("java.class.path");
  String[] paths = classpath.split(":");
  List<String> fnames = new LinkedList<>();
  for (String cp : paths) {
    File f = new File(cp);
    if (!f.isDirectory()) {
      continue;
    }
    DirectoryScanner ds = new DirectoryScanner();
    ds.setBasedir(f);
    ds.setIncludes(new String[]{"**\\*.class"});
    ds.scan();
    for (String name : ds.getIncludedFiles()) {
      fnames.add(new File(f, name).getAbsolutePath());
    }

  }
  return fnames.toArray(new String[]{});
}
 
開發者ID:apache,項目名稱:apex-core,代碼行數:22,代碼來源:OperatorDiscoveryTest.java

示例4: removeFileContaining

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private void removeFileContaining(String content) {
	DirectoryScanner ds = new DirectoryScanner();
	String[] includes = {"**/*.process"};
	ds.setIncludes(includes);
	ds.setBasedir(testSrcDirectory);
	//ds.setCaseSensitive(true);

	ContainsSelector contentToRemove = new ContainsSelector();
	contentToRemove.setText(content);

	FileSelector[] selectors = {contentToRemove};
	ds.setSelectors(selectors);
	ds.scan();

	String[] files = ds.getIncludedFiles();
	for (int i = 0; i < files.length; i++) {
		String file = testSrcDirectory + File.separator + files[i];
		getLog().debug("Deleting file with starter : '" + file + "'");
		getLog().info("Deleting file with starter : '" + file + "'");
		FileUtils.deleteQuietly(new File(file));
	}

}
 
開發者ID:fastconnect,項目名稱:tibco-fcunit,代碼行數:24,代碼來源:PrepareTestMojo.java

示例5: downloadProjectSDK

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
 * Downloads an SDK for needed language.
 *
 * @param lang     SDK language
 * @param response standard response
 * @throws SandboxServiceException if couldn't download
 */
@RequestMapping(value = "demoProjects/download/sdk/{lang}", method = RequestMethod.GET)
public void downloadProjectSDK(@PathVariable String lang, HttpServletResponse response) throws SandboxServiceException {
    String sdkPath = "/usr/lib/kaa-node/sdk/" + lang + "/";
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setIncludes(new String[]{"kaa-*"});
    scanner.setBasedir(sdkPath);
    scanner.setCaseSensitive(false);
    try {
        scanner.scan();
        String[] files = scanner.getIncludedFiles();
        if (files.length == 0) {
            LOG.warn("No SDK found for language [{}]", lang);
            return;
        }
        String sdkFullName = sdkPath + files[0];
        LOG.info("Downloading SDK [{}]", sdkFullName);
        response.setHeader("Content-disposition", "attachment; filename=" + files[0]);
        IOUtils.copy(Files.newInputStream(Paths.get(sdkFullName)), response.getOutputStream());
        response.flushBuffer();
    } catch (IOException e) {
        LOG.error("Couldn't download SDK for language [{}]", lang);
        throw new SandboxServiceException(e);
    }
}
 
開發者ID:kaaproject,項目名稱:sandbox-frame,代碼行數:32,代碼來源:SandboxController.java

示例6: removeTestClasses

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
 * Remove as classes de teste do sistema, para que elas nao entrem na
 * analise. Todos os diretorios cujo nome comeca com 'test' (test*) serão
 * excluídos.
 */
public void removeTestClasses() {
	System.out.println("Deleting test folders");
	DirectoryScanner scanner = new DirectoryScanner();
	String[] includes = { "**/test*" };
	scanner.setIncludes(includes);
	scanner.setBasedir(src_path);
	scanner.setCaseSensitive(false);
	scanner.scan();

	String[] included_dirs = scanner.getIncludedDirectories();
	for (String test_dir : included_dirs) {
		File dirToDelete = new File(src_path, test_dir);
		if (dirToDelete.exists())
			FileUtils.deleteRecursive(dirToDelete);
	}
}
 
開發者ID:aserg-ufmg,項目名稱:ModularityCheck,代碼行數:22,代碼來源:VersionControlManager.java

示例7: verifyPathAdheresToDesign

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private void verifyPathAdheresToDesign(Design d, Path p) throws ClassFormatException, IOException {
	String files[] = p.list();
	for (int i = 0; i < files.length; i++) {
		File file = new File(files[i]);
		if (file.isDirectory()) {
			FileSet set = new FileSet();
			set.setDir(file);
			set.setProject(task.getProject());
			PatternSet.NameEntry entry1 = set.createInclude();
			PatternSet.NameEntry entry2 = set.createInclude();
			PatternSet.NameEntry entry3 = set.createInclude();
			entry1.setName("**/*.class");
			entry2.setName("**/*.jar");
			entry3.setName("**/*.war");
			DirectoryScanner scanner = set.getDirectoryScanner(task.getProject());
			scanner.setBasedir(file);
			String[] scannerFiles = scanner.getIncludedFiles();
			for (int j = 0; j < scannerFiles.length; j++) {
				verifyPartOfPath(scannerFiles[j], new File(file, scannerFiles[j]), d);
			}
		} else
			verifyPartOfPath(files[i], file, d);
	}
}
 
開發者ID:cniweb,項目名稱:ant-contrib,代碼行數:25,代碼來源:VerifyDesignDelegate.java

示例8: findJsonFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private String[] findJsonFiles(File targetDirectory, String fileIncludePattern, String fileExcludePattern) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir(targetDirectory);

    if (StringUtils.isEmpty(fileIncludePattern)) {
        scanner.setIncludes(new String[]{DEFAULT_FILE_INCLUDE_PATTERN});
    } else {
        scanner.setIncludes(new String[]{fileIncludePattern});
    }
    if (StringUtils.isNotEmpty(fileExcludePattern)) {
        scanner.setExcludes(new String[]{fileExcludePattern});
    }
    scanner.setBasedir(targetDirectory);
    scanner.scan();
    return scanner.getIncludedFiles();
}
 
開發者ID:jenkinsci,項目名稱:cucumber-reports-plugin,代碼行數:17,代碼來源:CucumberReportPublisher.java

示例9: getFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public Collection<IFile> getFiles() {
    final DirectoryScanner ds = new DirectoryScanner();
    ds.setBasedir(basedir);
    ds.setIncludes(new String[] { pattern });
    ds.addDefaultExcludes();
    ds.scan();
    final String[] filenames = ds.getIncludedFiles();
    final Collection<IFile> files = new ArrayList<IFile>(
            filenames.length);
    for (final String name : filenames) {
        final String normName = name.replace(File.separatorChar, '/');
        files.add(new PhysicalFile(normName, new File(basedir, name)));
    }
    return files;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:Files.java

示例10: listFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
 * List all files matching specified patterns under specified base directory.
 * 
 * @param baseDir 
 * 			Base directory to scan files in
 * @param pathPattern 
 * 			Pattern of file path to be used for search
 * @return
 * 			Collection of files matching specified path pattern. Directories will not be included even 
 * 			if its path matches the pattern
 */
public static Collection<File> listFiles(File baseDir, String pathPattern) {
	Collection<File> files = new ArrayList<File>();
	
	DirectoryScanner scanner = new DirectoryScanner();
	scanner.setBasedir(baseDir);
	scanner.setIncludes(new String[]{pathPattern});
	scanner.scan();
	
	for (String path: scanner.getIncludedFiles()) 
		files.add(new File(baseDir, path));
	return files;
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:24,代碼來源:FileUtils.java

示例11: getFilesMatchingPattern

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public String[] getFilesMatchingPattern(File directory, String pattern) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir(directory);
    scanner.setIncludes(pattern.trim().split(" *, *"));
    scanner.scan();
    return scanner.getIncludedFiles();
}
 
開發者ID:tomzo,項目名稱:gocd-yaml-config-plugin,代碼行數:9,代碼來源:AntDirectoryScanner.java

示例12: invoke

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public Boolean invoke(File f, VirtualChannel channel) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setIncludes(DEFAULT_FILE_INCLUDES);
    scanner.setBasedir(f);
    scanner.scan();
    return scanner.getIncludedFilesCount() != 0;
}
 
開發者ID:DonutReport,項目名稱:donut-jenkins-plugin,代碼行數:9,代碼來源:DonutReportGenerator.java

示例13: listFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private String[] listFiles(String baseDir, String pattern) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir(baseDir);
    scanner.setIncludes(new String[]{pattern});
    scanner.scan();
    return scanner.getIncludedFiles();
}
 
開發者ID:nassendelft,項目名稱:jenkins-plugin-google-driver-uploader,代碼行數:8,代碼來源:GoogleDriveUploader.java

示例14: scanPath

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
 * Scans the given path and retrieves all files for the given path.
 *
 * @param path      A path to scan.
 * @param pathIndex The index of the given path. Used in log messages only.
 * @return A list of files, extracted from the given path.
 */
private List<File> scanPath(Path path, int pathIndex) {
    final String[] resources = path.list();
    log(pathIndex + ") Scanning path " + path, Project.MSG_VERBOSE);
    final List<File> allFiles = new ArrayList<File>();
    int concreteFilesCount = 0;

    for (String resource : resources) {
        final File file = new File(resource);
        if (file.isFile()) {
            concreteFilesCount++;
            allFiles.add(file);
        }
        else {
            final DirectoryScanner scanner = new DirectoryScanner();
            scanner.setBasedir(file);
            scanner.scan();
            final List<File> scannedFiles = retrieveAllScannedFiles(scanner, pathIndex);
            allFiles.addAll(scannedFiles);
        }
    }

    if (concreteFilesCount > 0) {
        log(String.format(Locale.ROOT, "%d) Adding %d files from path %s",
            pathIndex, concreteFilesCount, path), Project.MSG_VERBOSE);
    }

    return allFiles;
}
 
開發者ID:rnveach,項目名稱:checkstyle-backport-jre6,代碼行數:36,代碼來源:CheckstyleAntTask.java

示例15: getFiles

import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public List<File> getFiles(String rootPath, String wildCardPattern) {
    List<File> allFiles = new ArrayList<>();
    File file = new File(rootPath);
    if (file.isFile()) {
        allFiles.add(file);
        return allFiles;
    }

    if (!wildCardPattern.equals("")) {
        rootPath = rootPath.replace(wildCardPattern, "");
    }

    DirectoryScanner scanner = new DirectoryScanner();
    try {
        scanner.setBasedir(rootPath);
        scanner.setIncludes(new String[]{wildCardPattern});
        scanner.scan();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }

    if (wildCardPattern.equals("**")) {
        File directory = scanner.getBasedir();
        allFiles.add(directory);

        return allFiles;
    }

    String[] files = scanner.getIncludedFiles();
    for (String f : files) {
        allFiles.add(new File(rootPath, f));
    }

    return allFiles;
}
 
開發者ID:rndsolutions,項目名稱:hawkcd,代碼行數:37,代碼來源:FileManagementService.java


注:本文中的org.apache.tools.ant.DirectoryScanner.setBasedir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。