本文整理汇总了Java中com.android.utils.FileUtils类的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileUtils类属于com.android.utils包,在下文中一共展示了FileUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: generate
import com.android.utils.FileUtils; //导入依赖的package包/类
/**
* Directory of so
*/
@TaskAction
void generate() throws IOException, DocumentException {
Project project = getProject();
File apBaseFile = null;
File apFile = getApFile();
if (null != apFile && apFile.exists()) {
apBaseFile = apFile;
} else {
String apDependency = getApDependency();
if (StringUtils.isNotBlank(apContext.getApDependency())) {
Dependency dependency = project.getDependencies().create(apDependency);
Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
configuration.setTransitive(false);
configuration.getResolutionStrategy().cacheChangingModulesFor(0, TimeUnit.MILLISECONDS);
configuration.getResolutionStrategy().cacheDynamicVersionsFor(0, TimeUnit.MILLISECONDS);
for (File file : configuration.getFiles()) {
if (file.getName().endsWith(".ap")) {
apBaseFile = file;
break;
}
}
}
}
if (null != apBaseFile && apBaseFile.exists()) {
try {
explodedDir = getExplodedDir();
BetterZip.unzipDirectory(apBaseFile, explodedDir);
apContext.setApExploredFolder(explodedDir);
Set<String> awbBundles = getAwbBundles();
if (awbBundles != null) {
// Unzip the baseline Bundle
for (String awbBundle : awbBundles) {
File awbFile = BetterZip.extractFile(new File(explodedDir, AP_INLINE_APK_FILENAME),
"lib/armeabi/" + awbBundle,
new File(explodedDir, AP_INLINE_AWB_EXTRACT_DIRECTORY));
File awbExplodedDir = new File(new File(explodedDir, AP_INLINE_AWB_EXPLODED_DIRECTORY),
FilenameUtils.getBaseName(awbBundle));
BetterZip.unzipDirectory(awbFile, awbExplodedDir);
FileUtils.renameTo(new File(awbExplodedDir, FN_APK_CLASSES_DEX),
new File(awbExplodedDir, "classes2.dex"));
}
// Preprocessing increment androidmanifest.xml
ManifestFileUtils.updatePreProcessBaseManifestFile(
FileUtils.join(explodedDir, "manifest-modify", ANDROID_MANIFEST_XML),
new File(explodedDir, ANDROID_MANIFEST_XML));
}
if (explodedDir.listFiles().length == 0){
throw new RuntimeException("unzip ap exception, no files found");
}
}catch (Throwable e){
FileUtils.deleteIfExists(apBaseFile);
throw new GradleException(e.getMessage(),e);
}
}
}
开发者ID:alibaba,项目名称:atlas,代码行数:64,代码来源:PrepareAPTask.java
示例17: getPngsOutputDir
import com.android.utils.FileUtils; //导入依赖的package包/类
public File getPngsOutputDir(AwbBundle awbBundle) {
return FileUtils.join(new File(scope.getGlobalScope().getGeneratedDir().getParentFile(),
"awb-generated"),
StringHelper.toStrings("res", "pngs", scope.getDirectorySegments(),
awbBundle.getName()));
}
开发者ID:alibaba,项目名称:atlas,代码行数:7,代码来源:VariantContext.java
示例18: getAwbApkFiles
import com.android.utils.FileUtils; //导入依赖的package包/类
@NonNull
public Collection<File> getAwbApkFiles() {
return FileUtils.find(getAwbApkOutputDir(), Pattern.compile("\\.so$"));
}
开发者ID:alibaba,项目名称:atlas,代码行数:5,代码来源:AppVariantContext.java
示例19: emptyFolder
import com.android.utils.FileUtils; //导入依赖的package包/类
protected void emptyFolder(File folder) {
getLogger().info("deleteDir(" + folder + ") returned: " + FileUtils.deleteFolder(folder));
folder.mkdirs();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:BaseTask.java
示例20: createPngFiles
import com.android.utils.FileUtils; //导入依赖的package包/类
public Collection<File> createPngFiles(
@NonNull File inputXmlFile,
@NonNull File outputResDirectory,
@NonNull Collection<Density> densities) throws IOException {
checkArgument(inputXmlFile.exists());
checkArgument(outputResDirectory.exists());
checkArgument(
isInDrawable(inputXmlFile),
"XML file is not in a 'drawable-*' folder, [%s].",
inputXmlFile);
FolderConfiguration originalConfiguration = getFolderConfiguration(inputXmlFile);
// Create all the PNG files and duplicate the XML into folders with the version qualifier.
Collection<File> createdFiles = Lists.newArrayList();
for (Density density : densities) {
FolderConfiguration newConfiguration = FolderConfiguration.copyOf(originalConfiguration);
newConfiguration.setDensityQualifier(new DensityQualifier(density));
File directory = new File(
outputResDirectory,
newConfiguration.getFolderName(ResourceFolderType.DRAWABLE));
File pngFile = new File(
directory,
inputXmlFile.getName().replace(".xml", ".png"));
Files.createParentDirs(pngFile);
Files.write(
String.format(
"%s in %s, %s%n",
inputXmlFile.getName(),
density.getResourceValue(),
// For testing, make sure different inputs produce different outputs.
FileUtils.sha1(inputXmlFile)),
pngFile,
Charsets.UTF_8);
createdFiles.add(pngFile);
newConfiguration.setVersionQualifier(new VersionQualifier(MIN_SDK_WITH_VECTOR_SUPPORT));
File xmlCopy = copyOriginalXml(inputXmlFile, outputResDirectory, newConfiguration);
createdFiles.add(xmlCopy);
}
return createdFiles;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:VectorDrawableRenderer.java
注:本文中的com.android.utils.FileUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论