/** * Uncompress zipped stream in targetDir. * * @param stream the zip source stream, stream is closed before return * @param targetDir the destination directory * @throws IOException if any problem while unzip * @since 2.6.6 */ public static void uncompress(InputStream stream, File targetDir) throws IOException { uncompressAndRename(stream, targetDir, null, null); }
File target = new File(targetDir, name); if (entry.isDirectory()) { createDirectoryIfNecessary(target); } else { createDirectoryIfNecessary(target.getParentFile()); try (InputStream in = zipFile.getInputStream(entry)) { try (OutputStream out = new BufferedOutputStream(new FileOutputStream(target))) {
@Override protected void createUserI18nLayout(Path directory, I18nLanguageProvider delegateLanguageProvider) throws Exception { if (config.getI18nDefinitionFile().exists()) { return; } super.createUserI18nLayout(directory,delegateLanguageProvider); // add also a archive with all i18n stuff (says i18n bundle + templates) URL resource = resourceManager.getResourceUrl(I18N_ARCHIVE); File archive = new File(directory.getParent().toFile(), resourceManager.getResourceFilename(I18N_ARCHIVE)); try { getResourceManager().copyResource(resource, archive, String.format("%s Copy i18n archive", ApplicationBoot.BOOT_LOG_PREFIX)); Zips.uncompressFiltred(archive, directory.toFile().getParentFile()); } finally { if (Files.exists(archive.toPath())) { try { Files.delete(archive.toPath()); } catch (IOException e) { log.error(String.format("Could not delete i18n archive %s", archive)); } } } } };
public void unzipToDirectory(String resourceName, ApplicationConfiguration config, ConfigOptionDef option) throws IOException { File dir = config.get().getOptionAsFile(option.getKey()); createDirectory(dir); URL resourceUrl = getResourceUrl(resourceName); try (InputStream inputStream = openInternalStream(resourceUrl)) { Zips.uncompress(inputStream, dir); } }
createDirectoryIfNecessary(target); } else { createDirectoryIfNecessary(target.getParentFile()); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(target))) { byte[] buffer = new byte[BUFFER_SIZE];