org.zeroturnaround.zip.commons.FileUtils Java Examples

The following examples show how to use org.zeroturnaround.zip.commons.FileUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultPackageReader.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
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) {
		throw new SkipperException("Error reading yaml file", e);
	}
	PackageMetadata pkgMetadata = (PackageMetadata) yaml.load(fileContents);
	return pkgMetadata;
}
 
Example #2
Source File: PackrReduce.java    From packr with Apache License 2.0 6 votes vote down vote up
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);
	}
}
 
Example #3
Source File: PackrReduce.java    From packr with Apache License 2.0 6 votes vote down vote up
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;
	}
 
Example #4
Source File: BatteryFiles.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
public static Template asTemplate(final File fullPath) throws IOException {
    final Configuration templates = new Configuration(Configuration.VERSION_2_3_26);
    return new Template(fullPath.getName(), FileUtils.readFileToString(fullPath), templates);
}
 
Example #5
Source File: PackrConfig.java    From packr with Apache License 2.0 4 votes vote down vote up
private void readConfigJson(File configJson) throws IOException {

		JsonObject json = JsonObject.readFrom(FileUtils.readFileToString(configJson));

		if (json.get("platform") != null) {
			platform = Platform.byDesc(json.get("platform").asString());
		}
		if (json.get("jdk") != null) {
			jdk = json.get("jdk").asString();
		}
		if (json.get("executable") != null) {
			executable = json.get("executable").asString();
		}
		if (json.get("classpath") != null) {
			classpath = toStringArray(json.get("classpath").asArray());
		}
		if (json.get("removelibs") != null) {
			removePlatformLibs = toStringArray(json.get("removelibs").asArray());
		}
		if (json.get("mainclass") != null) {
			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());
		}
		if (json.get("output") != null) {
			outDir = new File(json.get("output").asString());
		}
		if (json.get("libs") != null) {
			platformLibsOutDir = new File(json.get("libs").asString());
		}
		if (json.get("icon") != null) {
			iconResource = new File(json.get("icon").asString());
		}
		if (json.get("bundle") != null) {
			bundleIdentifier = json.get("bundle").asString();
		}
	}
 
Example #6
Source File: ZipFileUtilTest.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@AfterEach
void afterMethod() throws IOException {
  FileUtils.deleteDirectory(tempDir);
}