当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.getFileUtils方法代码示例

本文整理汇总了Java中org.apache.tools.ant.util.FileUtils.getFileUtils方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getFileUtils方法的具体用法?Java FileUtils.getFileUtils怎么用?Java FileUtils.getFileUtils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tools.ant.util.FileUtils的用法示例。


在下文中一共展示了FileUtils.getFileUtils方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addFiles

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
protected void addFiles(File base, String[] files, Commandline cmdl)
{
    FileUtils utils = FileUtils.getFileUtils();

    if (spec == null)
    {
        for (int i = 0; i < files.length; i++)
        {
            cmdl.createArgument().setValue(utils.resolveFile(base, files[i]).getAbsolutePath());
        }
    }
    else
    {
        for (int i = 0; i < files.length; i++)
        {
            cmdl.createArgument().setValue("-" + spec.getFullName() + equalString() +
                                           utils.resolveFile(base, files[i]).getAbsolutePath());
        }
    }
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:21,代码来源:FlexFileSet.java

示例2: addFiles

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
protected void addFiles(File base, String[] files, Commandline cmdl)
{
    FileUtils utils = FileUtils.getFileUtils();
 
    for (int i = 0; i < files.length; ++i)
    {
        File f = utils.resolveFile(base, files[i]);
        String absolutePath = f.getAbsolutePath();

        if( f.isFile() && !absolutePath.endsWith(".swc") && !absolutePath.endsWith(".ane") )
        	continue;

        if (spec != null)
        {
            cmdl.createArgument().setValue("-" + spec.getFullName() + equalString() + absolutePath);
        }
        else
        {
            cmdl.createArgument().setValue(absolutePath);
        }
    }    
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:23,代码来源:FlexSwcFileSet.java

示例3: collectFileListFromModulePath

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
private void collectFileListFromModulePath() {
    final FileUtils fu = FileUtils.getFileUtils();
    for (String pathElement : moduleSourcepath.list()) {
        boolean valid = false;
        for (Map.Entry<String, Collection<File>> modules : resolveModuleSourcePathElement(
            getProject().getBaseDir(), pathElement).entrySet()) {
            final String moduleName = modules.getKey();
            for (File srcDir : modules.getValue()) {
                if (srcDir.exists()) {
                    valid = true;
                    final DirectoryScanner ds = getDirectoryScanner(srcDir);
                    final String[] files = ds.getIncludedFiles();
                    scanDir(srcDir, fu.resolveFile(destDir, moduleName), files);
                }
            }
        }
        if (!valid) {
            throw new BuildException("modulesourcepath \""
                                     + pathElement
                                     + "\" does not exist!", getLocation());
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:Javac.java

示例4: findModules

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
/**
 * Finds modules in the expanded modulesourcepath entry.
 * @param root the project root
 * @param pathToModule the path to modules folder
 * @param pathInModule the path in module to source folder
 * @param collector the map to put modules into
 * @since 1.9.7
 */
private static void findModules(
    final File root,
    final String pathToModule,
    final String pathInModule,
    final Map<String,Collection<File>> collector) {
    final FileUtils fu = FileUtils.getFileUtils();
    final File f = fu.resolveFile(root, pathToModule);
    if (!f.isDirectory()) {
        return;
    }
    for (File module : f.listFiles(File::isDirectory)) {
        final String moduleName = module.getName();
        final File moduleSourceRoot = pathInModule == null ?
                module :
                new File(module, pathInModule);
        Collection<File> moduleRoots = collector.get(moduleName);
        if (moduleRoots == null) {
            moduleRoots = new ArrayList<>();
            collector.put(moduleName, moduleRoots);
        }
        moduleRoots.add(moduleSourceRoot);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:32,代码来源:Javac.java

示例5: encodeDecode

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
@Test
public void encodeDecode() {
    Random rand = new Random();
    DummyDataSet.createDummyDataSet(context);

    List<Data> datas = HelperFactory.getDataHelper(context).getDataObjects(0, 4);
    for (Data data:datas) {
        if (data.getFile() != null && !data.getFile().exists()) {
            continue;
        }

        DataEncoder encoder = new StreamDataEncoder(data);
        StreamDataDecoder decoder = new StreamDataDecoder(context, data.getSender().getNetworkingId());

        while (encoder.available() > 0) {
            byte[] bytes = new byte[rand.nextInt(encoder.available() + 1)];
            int read = encoder.read(bytes, 0, bytes.length);
            decoder.write(bytes, 0, read);
        }
        Data decodedData = decoder.getDecodedData();

        assertNotNull("DecodedData should not be null", decodedData);
        assertEquals("Text should be equal!", data.getText(), decodedData.getText());
        assertEquals("sender should be equal!", data.getSender().getNetworkingId(), decodedData.getSender().getNetworkingId());
        assertEquals("Chat network identifier should be equal (Data)!", data.getNetworkChatID(), decodedData.getNetworkChatID());
        assertEquals("Chat network identifier should be equal (Decoder)!", data.getNetworkChatID(), decoder.getNetworkChatID());

        if (data.getFile() != null && data.getFile().exists()) {
            FileUtils fileUtils = FileUtils.getFileUtils();
            try {
                Assert.assertTrue("Send and received data should have the same file!", fileUtils.contentEquals(data.getFile(), decodedData.getFile()));
            } catch (IOException e) {
                Assert.assertTrue(e.getMessage(), false);
            }
        }
    }
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:38,代码来源:StreamDataDecoderTest.java

示例6: testPropertyResolution

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testPropertyResolution() throws Exception {
    FileUtils fu = FileUtils.getFileUtils();
    File props = fu.createTempFile("propertyfilecli", ".properties",
                                   null, true, true);
    File build = fu.createTempFile("propertyfilecli", ".xml", null, true,
                                   true);
    File log = fu.createTempFile("propertyfilecli", ".log", null, true,
                                 true);
    FileWriter fw = null;
    FileReader fr = null;
    try {
        fw = new FileWriter(props);
        fw.write("w=world\nmessage=Hello, ${w}\n");
        fw.close();
        fw = new FileWriter(build);
        fw.write("<project><echo>${message}</echo></project>");
        fw.close();
        fw = null;
        Main m = new NoExitMain();
        m.startAnt(new String[] {
                "-propertyfile", props.getAbsolutePath(),
                "-f", build.getAbsolutePath(),
                "-l", log.getAbsolutePath()
            }, null, null);
        String l = FileUtils.safeReadFully(fr = new FileReader(log));
        assertContains("Hello, world", l);
    } finally {
        FileUtils.close(fw);
        FileUtils.close(fr);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:33,代码来源:PropertyFileCLITest.java

示例7: tearDown

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
@After
public void tearDown() {
    if (f.exists()) {
        FileUtils fu = FileUtils.getFileUtils();
        fu.tryHardToDelete(f);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:8,代码来源:MessageTest.java

示例8: Copy

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
/**
 * Copy task constructor.
 */
public Copy() {
    fileUtils = FileUtils.getFileUtils();
    granularity = fileUtils.getFileTimestampGranularity();
}
 
开发者ID:apache,项目名称:ant,代码行数:8,代码来源:Copy.java

示例9: execute

import org.apache.tools.ant.util.FileUtils; //导入方法依赖的package包/类
/**
 * Sets a property, which must not already exist, with a space
 * separated list of files and directories relative to the jar
 * file's parent directory.
 */
@Override
public void execute() {
    if (name == null) {
        throw new BuildException("Missing 'property' attribute!");
    }
    if (dir == null) {
        throw new BuildException("Missing 'jarfile' attribute!");
    }
    if (getProject().getProperty(name) != null) {
        throw new BuildException("Property '%s' already set!", name);
    }
    if (path == null) {
        throw new BuildException("Missing nested <classpath>!");
    }

    StringBuilder tooLongSb = new StringBuilder();
    for (int i = 0; i < maxParentLevels + 1; i++) {
        tooLongSb.append("../");
    }
    final String tooLongPrefix = tooLongSb.toString();

    // Normalize the reference directory (containing the jar)
    final FileUtils fileUtils = FileUtils.getFileUtils();
    dir = fileUtils.normalize(dir.getAbsolutePath());

    String[] elements = path.list();
    StringBuilder buffer = new StringBuilder();
    for (String element : elements) {
        // Normalize the current file
        File pathEntry = new File(element);
        String fullPath = pathEntry.getAbsolutePath();
        pathEntry = fileUtils.normalize(fullPath);

        String relPath = null;
        String canonicalPath = null;
        try {
            if (dir.equals(pathEntry)) {
                relPath = ".";
            } else {
                relPath = FileUtils.getRelativePath(dir, pathEntry);
            }

            canonicalPath = pathEntry.getCanonicalPath();
            // getRelativePath always uses '/' as separator, adapt
            if (File.separatorChar != '/') {
                canonicalPath =
                    canonicalPath.replace(File.separatorChar, '/');
            }
        } catch (Exception e) {
            throw new BuildException("error trying to get the relative path"
                                     + " from " + dir + " to " + fullPath,
                                     e);
        }

        // No match, so bail out!
        if (relPath.equals(canonicalPath)
            || relPath.startsWith(tooLongPrefix)) {
            throw new BuildException(
                "No suitable relative path from %s to %s", dir, fullPath);
        }

        if (pathEntry.isDirectory() && !relPath.endsWith("/")) {
            relPath = relPath + '/';
        }
        relPath = Locator.encodeURI(relPath);

        // Manifest's ClassPath: attribute always uses forward
        // slashes '/', and is space-separated. Ant will properly
        // format it on 72 columns with proper line continuation
        buffer.append(relPath);
        buffer.append(' ');
    }

    // Finally assign the property with the manifest classpath
    getProject().setNewProperty(name, buffer.toString().trim());
}
 
开发者ID:apache,项目名称:ant,代码行数:82,代码来源:ManifestClassPath.java


注:本文中的org.apache.tools.ant.util.FileUtils.getFileUtils方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。