本文整理汇总了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--;
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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();
}
});
}
示例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));
}
}
示例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");
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例15: emptyFolder
import com.android.utils.FileUtils; //导入依赖的package包/类
protected void emptyFolder(File folder) throws IOException {
FileUtils.deletePath(folder);
folder.mkdirs();
}