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


Java FileSet.iterator方法代碼示例

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


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

示例1: getFilesByNameEntryFilter

import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
/**
 * Returns a list of files found in a given folder, matching a given filter.
 * @param folder the folder to search
 * @param filters the filter for the files. Typically a glob.
 * @return an iterator.
 */
private Iterator<?> getFilesByNameEntryFilter(String folder, String... filters) {
    Project taskProject = getProject();

    // create a fileset to find all the files in the folder
    FileSet fs = new FileSet();
    fs.setProject(taskProject);
    fs.setDir(new File(folder));
    for (String filter : filters) {
        NameEntry include = fs.createInclude();
        include.setName(filter);
    }

    // loop through the results of the file set
    return fs.iterator();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:MultiFilesTask.java

示例2: execute

import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Override
public void execute() throws BuildException {

    // get all input paths
    List<File> paths = new ArrayList<File>();
    if (mPathInputs != null) {
        for (Path pathList : mPathInputs) {
            for (String path : pathList.list()) {
                System.out.println("input: " + path);
                paths.add(new File(path));
            }
        }
    }

    if (mFileSetInputs != null) {
        for (FileSet fs : mFileSetInputs) {
            Iterator<?> iter = fs.iterator();
            while (iter.hasNext()) {
                FileResource fr = (FileResource) iter.next();
                System.out.println("input: " + fr.getFile().toString());
                paths.add(fr.getFile());
            }
        }
    }

    // pre dex libraries if needed
    preDexLibraries(paths);

    // figure out the path to the dependency file.
    String depFile = mOutput + ".d";

    // get InputPath with no extension restrictions
    List<InputPath> inputPaths = getInputPaths(paths, null /*extensionsToCheck*/,
            null /*factory*/);

    if (initDependencies(depFile, inputPaths) && dependenciesHaveChanged() == false) {
        System.out.println(
                "No new compiled code. No need to convert bytecode to dalvik format.");
        return;
    }

    System.out.println(String.format(
            "Converting compiled files and external libraries into %1$s...", mOutput));

    runDx(paths, mOutput, mVerbose /*showInputs*/);

    // generate the dependency file.
    generateDependencyFile(depFile, inputPaths, mOutput);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:50,代碼來源:DexExecTask.java

示例3: execute

import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
public void execute() throws BuildException {

	if (outputDir == null) {
	    throw new BuildException ("no output directory declared!");
	}

	if (!outputDir.exists()) {
	    throw new BuildException ("Output directory doesn't exist:" + outputDir);
	}

	String javaHome = System.getProperty("java.home");
	String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
        String classpath = System.getProperty("java.class.path");

	// add on our own paths
	String allPaths = "";
	for (Path p : paths) {
	    classpath  += ":" + p.toString();
	}

	for (FileSet fs : filesets) {

	    for (Iterator it = fs.iterator(); it.hasNext(); ) {
		FileResource res = (FileResource) it.next();
		
		// convert name into CLASS (trim .java and replace slashes)
		String name = res.getName();
		name = name.substring (0, name.length()-5);
		String className = name.replace('/', '.');
	    
		try {

		    ProcessBuilder builder = new ProcessBuilder(javaBin, "-cp", classpath, className);
		    Process process = builder.start();

		    // process output
		    InputStream is = process.getInputStream();
		    InputStreamReader isr = new InputStreamReader(is);
		    BufferedReader br = new BufferedReader (isr);
		    
		    File outFile = new File (outputDir, className + ".output");
		    PrintStream ps = new PrintStream (outFile);

		    // generic start/stop info for each output file.
		    Date d = new Date();
		    ps.println ("Start:" + d.getTime() + " [" + d + "]");

		    String s;
		    int nb = 0;
		    while ((s = br.readLine()) != null) {
			nb += s.length();
			ps.println(s);
		    }

		    // generic end
		    d = new Date();
		    ps.println ("End:" + d.getTime() + " [" + d + "]");

		    ps.close();

		    int ev = process.exitValue();
		    System.out.println (className + " [" + nb + " bytes output, exit code:" + ev + "]");
		    
		} catch (Exception e) {
		    throw new BuildException ("unable to process class " + className + ": " + e.getMessage());
		}
	    }
	}
    }
 
開發者ID:heineman,項目名稱:algorithms-nutshell-2ed,代碼行數:70,代碼來源:RunAll.java


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