/** * Extract all files from a zip file into a directory. * * @param zipFile the input zip file * @param outputFolder the output folder for extracted files */ public static void extractAll(File zipFile, File outputFolder) throws IOException { extractAll(zipFile, StandardCharsets.UTF_8, outputFolder); }
try { originalZipFolder = Files.createTempDirectory("openl").toFile(); ZipUtils.extractAll(zipFile, originalZipFolder); ZipUtils.archive(originalZipFolder, modifiedZip); modifiedZipStream = new FileInputStream(modifiedZip);
/** * Pack all files in a directory to a zip file. * * @param sourceDirectory * @param targetFile * @throws IOException */ public static void archive(File sourceDirectory, File targetFile) throws IOException { if (!sourceDirectory.exists()) { throw new FileNotFoundException("File '" + sourceDirectory.getAbsolutePath() + "' is not exist!"); } if (sourceDirectory.isDirectory()) { String[] list = sourceDirectory.list(); if (list == null || list.length == 0) { throw new FileNotFoundException("Directory '" + sourceDirectory.getAbsolutePath() + "' is empty!"); } } OutputStream fos = new FileOutputStream(targetFile); try { archive(sourceDirectory, fos); } finally { fos.close(); } }
archiveFile(file, entryName, zos, buffer); archiveFile(source, name, zos, buffer);
try { originalZipFolder = Files.createTempDirectory("openl").toFile(); ZipUtils.extractAll(zipFile, originalZipFolder); ZipUtils.archive(originalZipFolder, modifiedZip); modifiedZipStream = new FileInputStream(modifiedZip);
/** * Pack all files in a directory to a zip file. * * @param sourceDirectory * @param targetFile * @throws IOException */ public static void archive(File sourceDirectory, File targetFile) throws IOException { if (!sourceDirectory.exists()) { throw new FileNotFoundException("File '" + sourceDirectory.getAbsolutePath() + "' is not exist!"); } if (sourceDirectory.isDirectory()) { String[] list = sourceDirectory.list(); if (list == null || list.length == 0) { throw new FileNotFoundException("Directory '" + sourceDirectory.getAbsolutePath() + "' is empty!"); } } OutputStream fos = new FileOutputStream(targetFile); try { archive(sourceDirectory, fos); } finally { fos.close(); } }
archiveFile(file, entryName, zos, buffer); archiveFile(source, name, zos, buffer);
/** * Extract all files from a zipped stream into a directory. * * @param zippedStream the zipped input stream * @param outputFolder the output folder for extracted files */ public static void extractAll(InputStream zippedStream, File outputFolder) throws IOException { extractAll(zippedStream, StandardCharsets.UTF_8, outputFolder); }
/** * Extract all files from a zipped stream into a directory. * * @param zippedStream the zipped input stream * @param outputFolder the output folder for extracted files */ public static void extractAll(InputStream zippedStream, File outputFolder) throws IOException { extractAll(zippedStream, StandardCharsets.UTF_8, outputFolder); }
/** * Extract all files from a zip file into a directory. * * @param zipFile the input zip file * @param outputFolder the output folder for extracted files */ public static void extractAll(File zipFile, File outputFolder) throws IOException { extractAll(zipFile, StandardCharsets.UTF_8, outputFolder); }
/** * Extract all files from a zip file into a directory. * * @param zipFile the input zip file * @param charset charset used to uncompress zip from input stream * @param outputFolder the output folder for extracted files */ public static void extractAll(File zipFile, Charset charset, File outputFolder) throws IOException { final FileInputStream zippedStream = new FileInputStream(zipFile); extractAll(zippedStream, charset, outputFolder); }
/** * Extract all files from a zip file into a directory. * * @param zipFile the input zip file * @param charset charset used to uncompress zip from input stream * @param outputFolder the output folder for extracted files */ public static void extractAll(File zipFile, Charset charset, File outputFolder) throws IOException { final FileInputStream zippedStream = new FileInputStream(zipFile); extractAll(zippedStream, charset, outputFolder); }
public static File prepareDeploymentOpenLResource(String deploymentId, String resource) throws IOException { RepositoryService repositoryService = Context.getProcessEngineConfiguration().getRepositoryService(); InputStream inputStream = repositoryService.getResourceAsStream(deploymentId, resource); if (inputStream == null) { throw new ResourceNotFoundException(String.format("No resource found with name '%s'!", resource)); } final File workspaceFolder = Files.createTempDirectory("openl").toFile(); if (resource.endsWith(".zip")) { // Unzip ZipUtils.extractAll(inputStream, workspaceFolder); } else { // Copy File resourceFile = new File(workspaceFolder, resource); FileOutputStream fos = new FileOutputStream(resourceFile); IOUtils.copyAndClose(inputStream, fos); } Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { FileUtils.deleteQuietly(workspaceFolder); } }); return workspaceFolder; } }
public static File prepareDeploymentOpenLResource(String deploymentId, String resource) throws IOException { RepositoryService repositoryService = Context.getProcessEngineConfiguration().getRepositoryService(); InputStream inputStream = repositoryService.getResourceAsStream(deploymentId, resource); if (inputStream == null) { throw new ResourceNotFoundException(String.format("No resource found with name '%s'!", resource)); } final File workspaceFolder = Files.createTempDirectory("openl").toFile(); if (resource.endsWith(".zip")) { // Unzip ZipUtils.extractAll(inputStream, workspaceFolder); } else { // Copy File resourceFile = new File(workspaceFolder, resource); FileOutputStream fos = new FileOutputStream(resourceFile); IOUtils.copyAndClose(inputStream, fos); } Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { FileUtils.deleteQuietly(workspaceFolder); } }); return workspaceFolder; } }
ZipUtils.extractAll(zipFile, zipFolder);
ZipUtils.extractAll(zipFile, zipFolder);
ZipUtils.extractAll(file, destDir); recreateFolderIfExists(d); ZipUtils.extractAll(file, d);
ZipUtils.extractAll(file, destDir); recreateFolderIfExists(d); ZipUtils.extractAll(file, d);
File projectFolder = new File(workspaceFolder, artifact.getArtifactId()); if (!projectFolder.exists()) { ZipUtils.extractAll(artifact.getFile(), projectFolder);
File projectFolder = new File(workspaceFolder, artifact.getArtifactId()); if (!projectFolder.exists()) { ZipUtils.extractAll(artifact.getFile(), projectFolder);