本文整理汇总了Java中org.zeroturnaround.zip.commons.FileUtils类的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileUtils类属于org.zeroturnaround.zip.commons包,在下文中一共展示了FileUtils类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadPackageMetadata
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
private PackageMetadata loadPackageMetadata(File file) {
// The Representer will not try to set the value in the YAML on the
// Java object if it isn't present on the object
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(PackageMetadata.class), representer);
String fileContents = null;
try {
fileContents = FileUtils.readFileToString(file);
}
catch (IOException e) {
e.printStackTrace();
}
PackageMetadata pkgMetadata = (PackageMetadata) yaml.load(fileContents);
return pkgMetadata;
}
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:17,代码来源:DefaultPackageReader.java
示例2: removeFile
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
private static void removeFile(File file, PackrConfig config) throws IOException {
if (!file.exists()) {
if (config.verbose) {
System.out.println(" # No file or directory '" + file.getPath() + "' found");
}
return;
}
if (config.verbose) {
System.out.println(" # Removing '" + file.getPath() + "'");
}
if (file.isDirectory()) {
FileUtils.deleteDirectory(file);
} else {
PackrFileUtils.delete(file);
}
}
开发者ID:libgdx,项目名称:packr,代码行数:19,代码来源:PackrReduce.java
示例3: readMinimizeProfile
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
private static JsonObject readMinimizeProfile(PackrConfig config) throws IOException {
JsonObject json = null;
if (new File(config.minimizeJre).exists()) {
json = JsonObject.readFrom(FileUtils.readFileToString(new File(config.minimizeJre)));
} else {
InputStream in = Packr.class.getResourceAsStream("/minimize/" + config.minimizeJre);
if (in != null) {
json = JsonObject.readFrom(new InputStreamReader(in));
}
}
if (json == null && config.verbose) {
System.out.println(" # No minimize profile '" + config.minimizeJre + "' found");
}
return json;
}
开发者ID:libgdx,项目名称:packr,代码行数:20,代码来源:PackrReduce.java
示例4: readConfigJson
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
private void readConfigJson(File configJson) throws IOException {
JsonObject json = JsonObject.readFrom(FileUtils.readFileToString(configJson));
platform = Platform.byDesc(json.get("platform").asString());
jdk = json.get("jdk").asString();
executable = json.get("executable").asString();
classpath = toStringArray(json.get("classpath").asArray());
if (json.get("removelibs") != null) {
removePlatformLibs = toStringArray(json.get("removelibs").asArray());
}
mainClass = json.get("mainclass").asString();
if (json.get("vmargs") != null) {
List<String> vmArgs = toStringArray(json.get("vmargs").asArray());
this.vmArgs = new ArrayList<>();
for (String vmArg : vmArgs) {
if (vmArg.startsWith("-")) {
this.vmArgs.add(vmArg.substring(1));
} else {
this.vmArgs.add(vmArg);
}
}
}
if (json.get("minimizejre") != null) {
minimizeJre = json.get("minimizejre").asString();
}
if (json.get("cachejre") != null) {
cacheJre = new File(json.get("cachejre").asString());
}
if (json.get("resources") != null) {
resources = toFileArray(json.get("resources").asArray());
}
outDir = new File(json.get("output").asString());
if (json.get("icon") != null) {
iconResource = new File(json.get("icon").asString());
}
if (json.get("bundle") != null) {
bundleIdentifier = json.get("bundle").asString();
}
}
开发者ID:libgdx,项目名称:packr,代码行数:41,代码来源:PackrConfig.java
示例5: onRun
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
@Override
public void onRun() throws Throwable {
// Send zero progress event
EventBus.getDefault().post(new ExtractIssueProgressEvent(issue, 0));
// Delete directory if exists
if (outputDirectory.exists() && outputDirectory.isDirectory()) {
FileUtils.deleteDirectory(outputDirectory);
}
// Prepare progress
FileInputStream zipFileInputStream = new MonitorFileInputStream(zipFile);
// Unzip file
ZipUtil.unpack(zipFileInputStream, outputDirectory);
// Delete zip file
if(!this.zipFile.delete()) {
throw new Exception("Unable to remove issue hpub file");
}
// Post complete event
completed = true;
Log.i("ExtractZipJob", "completed");
EventBus.getDefault().post(new ExtractIssueCompleteEvent(issue));
}
开发者ID:bakerframework,项目名称:baker-android-refactor,代码行数:28,代码来源:ExtractIssueJob.java
示例6: moveToElasticsearchDirectory
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
private void moveToElasticsearchDirectory(File src, File dest) throws IOException
{
File[] files = src.listFiles(new FileFilter()
{
@Override
public boolean accept(final File file)
{
return file.isDirectory();
}
});
// should only be one
FileUtils.copyDirectory(files[0], dest);
}
开发者ID:alexcojocaru,项目名称:elasticsearch-maven-plugin,代码行数:15,代码来源:ResolveElasticsearchStep.java
示例7: mapJars
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
@TaskAction
public void mapJars() throws IOException, MappingParseException {
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
if (!Constants.MINECRAFT_MAPPED_JAR.get(extension).exists() || extension.localMappings) {
if(extension.localMappings && Constants.MINECRAFT_MAPPED_JAR.get(extension).exists()){
//Always remap the jar when using local mappings.
Constants.MINECRAFT_MAPPED_JAR.get(extension).delete();
}
if(!extension.hasPomf()){
this.getLogger().lifecycle("POMF version not set, skipping mapping!");
FileUtils.copyFile(Constants.MINECRAFT_MERGED_JAR.get(extension), Constants.MINECRAFT_MAPPED_JAR.get(extension));
return;
}
if (!Constants.MAPPINGS_DIR.get(extension).exists() || extension.localMappings) {
this.getLogger().lifecycle(":unpacking mappings");
FileUtils.deleteDirectory(Constants.MAPPINGS_DIR.get(extension));
ZipUtil.unpack(Constants.MAPPINGS_ZIP.get(extension), Constants.MAPPINGS_DIR.get(extension));
}
this.getLogger().lifecycle(":remapping jar");
deobfuscator = new Deobfuscator(new JarFile(Constants.MINECRAFT_MERGED_JAR.get(extension)));
this.deobfuscator.setMappings(new MappingsEnigmaReader().read(Constants.MAPPINGS_DIR.get(extension)));
writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator);
File tempAssests = new File(Constants.CACHE_FILES, "tempAssets");
if (tempAssests.exists()) {
FileUtils.deleteDirectory(tempAssests);
}
tempAssests.mkdir();
ZipUtil.unpack(Constants.MINECRAFT_CLIENT_JAR.get(extension), tempAssests, name -> {
if (name.startsWith("assets") || name.startsWith("log4j2.xml") || name.startsWith("pack.png")) {
return name;
} else {
return null;
}
});
ZipUtil.unpack(Constants.MINECRAFT_MAPPED_JAR.get(extension), tempAssests);
ZipUtil.pack(tempAssests, Constants.MINECRAFT_MAPPED_JAR.get(extension));
FileUtils.deleteDirectory(tempAssests);
} else {
this.getLogger().lifecycle(Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath());
this.getLogger().lifecycle(":mapped jar found, skipping mapping");
}
}
开发者ID:FabricMC,项目名称:fabric-loom,代码行数:47,代码来源:MapJarsTask.java
示例8: removePlatformLibs
import org.zeroturnaround.zip.commons.FileUtils; //导入依赖的package包/类
static void removePlatformLibs(PackrOutput output, PackrConfig config) throws IOException {
if (config.removePlatformLibs == null || config.removePlatformLibs.isEmpty()) {
return;
}
System.out.println("Removing foreign platform libs ...");
// let's remove any shared libs not used on the platform, e.g. libGDX/LWJGL natives
for (String classpath : config.removePlatformLibs) {
File jar = new File(output.resourcesFolder, new File(classpath).getName());
File jarDir = new File(output.resourcesFolder, jar.getName() + ".tmp");
if (config.verbose) {
if (jar.isDirectory()) {
System.out.println(" # JAR '" + jar.getName() + "' is a directory");
} else {
System.out.println(" # Unpacking '" + jar.getName() + "' ...");
}
}
if (!jar.isDirectory()) {
ZipUtil.unpack(jar, jarDir);
} else {
jarDir = jar; // run in-place for directories
}
Set<String> extensions = new HashSet<>();
switch (config.platform) {
case Windows32:
case Windows64:
extensions.add(".dylib");
extensions.add(".so");
break;
case Linux32:
case Linux64:
extensions.add(".dylib");
extensions.add(".dll");
break;
case MacOS:
extensions.add(".dll");
extensions.add(".so");
break;
}
File[] files = jarDir.listFiles();
if (files != null) {
for (File file : files) {
for (String extension : extensions) {
if (file.getName().endsWith(extension)) {
if (config.verbose) {
System.out.println(" # Removing '" + file.getPath() + "'");
}
PackrFileUtils.delete(file);
}
}
}
}
if (!jar.isDirectory()) {
if (config.verbose) {
System.out.println(" # Repacking '" + jar.getName() + "' ...");
}
long beforeLen = jar.length();
PackrFileUtils.delete(jar);
ZipUtil.pack(jarDir, jar);
FileUtils.deleteDirectory(jarDir);
long afterLen = jar.length();
if (config.verbose) {
System.out.println(" # " + beforeLen / 1024 + " kb -> " + afterLen / 1024 + " kb");
}
}
}
}
开发者ID:libgdx,项目名称:packr,代码行数:78,代码来源:PackrReduce.java
注:本文中的org.zeroturnaround.zip.commons.FileUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论