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


Java FileUtils类代码示例

本文整理汇总了Java中com.android.utils.FileUtils的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doFullTaskAction

import com.android.utils.FileUtils; //导入依赖的package包/类
@Override
protected void doFullTaskAction() throws IOException {
    File baseApk = getBaseApk();
    File outputDir = getOutputDir();
    FileUtils.deleteDirectoryContents(outputDir);
    BetterZip.unzipDirectory(baseApk, outputDir);
    FileUtils.deleteDirectoryContents(FileUtils.join(outputDir, "META-INF/"));
    int dexFilesCount = getDexFilesCount();
    Set<File> baseDexFileSet = getProject().fileTree(
        ImmutableMap.of("dir", outputDir, "includes", ImmutableList.of("classes*.dex"))).getFiles();
    File[] baseDexFiles = baseDexFileSet.toArray(new File[baseDexFileSet.size()]);
    int j = baseDexFileSet.size() + dexFilesCount;
    for (int i = baseDexFiles.length - 1; i >= 0; i--) {
        FileUtils.renameTo(baseDexFiles[i], new File(outputDir, "classes" + j + ".dex"));
        j--;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:18,代码来源:PrepareBaseApkTask.java

示例2: getOutputStream

import com.android.utils.FileUtils; //导入依赖的package包/类
/**
 * Get the task outputStream
 *
 * @param injectTransform
 * @param scope
 * @param taskName
 * @param <T>
 * @return
 */
@NotNull
private <T extends Transform> IntermediateStream getOutputStream(T injectTransform,
                                                                 @NonNull VariantScope scope,
                                                                 String taskName) {
    File outRootFolder = FileUtils.join(project.getBuildDir(),
                                        StringHelper.toStrings(AndroidProject.FD_INTERMEDIATES,
                                                               FD_TRANSFORMS,
                                                               injectTransform.getName(),
                                                               scope.getDirectorySegments()));

    Set<? super Scope> requestedScopes = injectTransform.getScopes();

    // create the output
    return IntermediateStream.builder()
            .addContentTypes(injectTransform.getOutputTypes())
            .addScopes(requestedScopes)
            .setRootLocation(outRootFolder)
            .setDependency(taskName)
            .build();
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:30,代码来源:InjectTransformManager.java

示例3: checkMergingFolder

import com.android.utils.FileUtils; //导入依赖的package包/类
/**
 * Checks the merger folder is:
 * - a directory.
 * - if the folder exists, that it can be modified.
 * - if it doesn't exists, that a new folder can be created.
 * @param file the File to check
 * @throws PackagerException If the check fails
 */
private static void checkMergingFolder(File file) throws PackagerException {
    if (file.isFile()) {
        throw new PackagerException("%s is a file!", file);
    }

    if (file.exists()) { // will be a directory in this case.
        if (!file.canWrite()) {
            throw new PackagerException("Cannot write %s", file);
        }
        FileUtils.deleteFolder(file);
    }

    if (!file.mkdirs()) {
        throw new PackagerException("Failed to create %s", file);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:Packager.java

示例4: getFolder

import com.android.utils.FileUtils; //导入依赖的package包/类
/**
 * Returns the folder used to store android related files.
 * If the folder is not created yet, it will be created here.
 * @return an OS specific path, terminated by a separator.
 * @throws AndroidLocationException
 */
public static String getFolder() throws AndroidLocationException {
    if (sPrefsLocation == null) {
        sPrefsLocation = findHomeFolder();
    }

    // make sure the folder exists!
    File f = new File(sPrefsLocation);
    if (!f.exists()) {
        try {
            FileUtils.mkdirs(f);
        } catch (SecurityException e) {
            AndroidLocationException e2 = new AndroidLocationException(String.format(
              "Unable to create folder '%1$s'. " +
              "This is the path of preference folder expected by the Android tools.",
              sPrefsLocation));
            e2.initCause(e);
            throw e2;
        }
    } else if (f.isFile()) {
        throw new AndroidLocationException(String.format(
          "%1$s is not a directory!\n" +
          "This is the path of preference folder expected by the Android tools.", sPrefsLocation));
    }
    return sPrefsLocation;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:32,代码来源:AndroidLocation.java

示例5: processAllResources

import com.android.utils.FileUtils; //导入依赖的package包/类
private void processAllResources() throws Exception {
    FileUtils.cleanOutputDir(outputDirectory);

    List<Path> inputs = Files.walk(inputPath).collect(Collectors.toList());

    for (Path path : inputs) {
        processSingleFile(path);
    }
}
 
开发者ID:benjamin-bader,项目名称:placeholders-plugin,代码行数:10,代码来源:PlaceholderReplacementTask.java

示例6: execute

import com.android.utils.FileUtils; //导入依赖的package包/类
@Override
public void execute(DexBuildTask dexBuildTask) {

    super.execute(dexBuildTask);

    ConventionMappingHelper.map(dexBuildTask, "classJar", new Callable<File>() {
        @Override
        public File call() throws Exception {

            GradleVariantConfiguration variantConfig = libVariantContext.getVariantConfiguration();
            File intermediatesDir = scope.getGlobalScope().getIntermediatesDir();
            Collection<String> variantDirectorySegments = variantConfig.getDirectorySegments();
            File variantBundleDir = FileUtils.join(
                intermediatesDir,
                StringHelper.toStrings(TaskManager.DIR_BUNDLES, variantDirectorySegments));
            return new File(variantBundleDir, FN_CLASSES_JAR);
        }
    });

    ConventionMappingHelper.map(dexBuildTask, "outputDexFile", new Callable<File>() {
        @Override
        public File call() throws Exception {
            return libVariantContext.getDex();
        }
    });

    ConventionMappingHelper.map(dexBuildTask, "dependencyJars", new Callable<List<File>>() {
        @Override
        public List<File> call() throws Exception {
            return libVariantContext.getJarDexList();
        }

    });

}
 
开发者ID:alibaba,项目名称:atlas,代码行数:36,代码来源:DexBuildTask.java

示例7: init

import com.android.utils.FileUtils; //导入依赖的package包/类
private void init() throws IOException {
    if (closer == null) {
        FileUtils.mkdirs(jarFile.getParentFile());

        closer = Closer.create();

        FileOutputStream fos = closer.register(new FileOutputStream(jarFile));
        jarOutputStream = closer.register(new JarOutputStream(fos));
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:11,代码来源:JarMergerWithOverride.java

示例8: getExploreDir

import com.android.utils.FileUtils; //导入依赖的package包/类
public static File getExploreDir(Project project, MavenCoordinates mavenCoordinates, File bundle, String type,
                                 String path) {

    if (!bundle.exists()) {
        project.getLogger().info("missing " + mavenCoordinates.toString());
    }

    Optional<FileCache> buildCache =
        AndroidGradleOptions.getBuildCache(project);
    File explodedDir;
    if (shouldUseBuildCache(project, mavenCoordinates, bundle, buildCache)) { //&& !"awb"
        // .equals(type)
        try {

            explodedDir = buildCache.get().getFileInCache(
                PrepareLibraryTask.getBuildCacheInputs(bundle));

            return explodedDir;

        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    } else {
        Preconditions.checkState(
            !AndroidGradleOptions
                .isImprovedDependencyResolutionEnabled(project),
            "Improved dependency resolution must be used with "
                + "build cache.");

        return FileUtils.join(
            project.getBuildDir(),
            FD_INTERMEDIATES,
            "exploded-" + type,
            path);
    }

    //throw new GradleException("set explored dir exception");

}
 
开发者ID:alibaba,项目名称:atlas,代码行数:40,代码来源:DependencyLocationManager.java

示例9: getBaseUnitTagMap

import com.android.utils.FileUtils; //导入依赖的package包/类
public Map<String, String> getBaseUnitTagMap() throws IOException {
    Map<String, String> tagMap = new HashMap<>();
    if (null != this.apContext.getApExploredFolder()
        && this.apContext.getApExploredFolder().exists()) {
        File file = new File(this.apContext.getApExploredFolder(), "atlasFrameworkProperties.json");
        if (file.exists()) {
            JSONObject jsonObject = (JSONObject)JSON.parse(org.apache.commons.io.FileUtils.readFileToString(file));
            JSONArray jsonArray = jsonObject.getJSONArray("bundleInfo");
            for (JSONObject obj : jsonArray.toArray(new JSONObject[0])) {
                tagMap.put(obj.getString("pkgName"), obj.getString("unique_tag"));
            }
        }
    }
    return tagMap;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:16,代码来源:AppVariantContext.java

示例10: setApExploredFolder

import com.android.utils.FileUtils; //导入依赖的package包/类
public void setApExploredFolder(File apExploredFolder) {
    this.apExploredFolder = apExploredFolder;
    this.baseManifest = new File(apExploredFolder, ANDROID_MANIFEST_XML);
    this.baseModifyManifest = FileUtils.join(apExploredFolder, "manifest-modify", ANDROID_MANIFEST_XML);
    this.baseApk = new File(apExploredFolder, AP_INLINE_APK_FILENAME);
    this.baseApkDirectory = new File(apExploredFolder, AP_INLINE_APK_EXTRACT_DIRECTORY);
    this.baseAwbDirectory = new File(apExploredFolder, AP_INLINE_AWB_EXTRACT_DIRECTORY);
    this.baseUnzipBundleDirectory = new File(apExploredFolder,SO_LOCATION_PREFIX);
    this.baseExplodedAwbDirectory = new File(apExploredFolder, AP_INLINE_AWB_EXPLODED_DIRECTORY);
    this.basePackageIdFile = new File(apExploredFolder, PACKAGE_ID_PROPERTIES_FILENAME);
    this.baseAtlasFrameworkPropertiesFile = new File(apExploredFolder, ATLAS_FRAMEWORK_PROPERTIES_FILENAME);
    this.baseDependenciesFile = new File(apExploredFolder, DEPENDENCIES_FILENAME);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:14,代码来源:ApContext.java

示例11: getBaseAwb

import com.android.utils.FileUtils; //导入依赖的package包/类
public File getBaseAwb(String soFileName) {
    File file = FileUtils.join(baseAwbDirectory, soFileName);
    if (!file.exists()) {
        return null;
    }
    return file;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:8,代码来源:ApContext.java

示例12: getBaseExplodedAwb

import com.android.utils.FileUtils; //导入依赖的package包/类
public File getBaseExplodedAwb(String soFileName) {
    File file = FileUtils.join(baseExplodedAwbDirectory, FilenameUtils.getBaseName(soFileName));
    if (!file.exists()) {
        return null;
    }
    return file;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:8,代码来源:ApContext.java

示例13: getBaseSo

import com.android.utils.FileUtils; //导入依赖的package包/类
public File getBaseSo(String soFileName){
    File file = FileUtils.join(baseUnzipBundleDirectory,soFileName);
    if (file.exists()){
        return file;
    }

    return null;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:9,代码来源:ApContext.java

示例14: getAdb

import com.android.utils.FileUtils; //导入依赖的package包/类
@NonNull
public static File getAdb() {
    File adb = FileUtils.join(findSdkDir(), SdkConstants.FD_PLATFORM_TOOLS, SdkConstants.FN_ADB);
    if (!adb.exists()) {
        throw new RuntimeException("Unable to find adb.");
    }
    return adb;
}
 
开发者ID:apptik,项目名称:tarator,代码行数:9,代码来源:SdkHelper.java

示例15: emptyFolder

import com.android.utils.FileUtils; //导入依赖的package包/类
protected void emptyFolder(File folder) throws IOException {
    FileUtils.deletePath(folder);
    folder.mkdirs();
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:5,代码来源:AwbDexTask.java


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