public static void unzip(InputStream is, String destDir) throws FileNotFoundException, IOException { unzip(is, new File(destDir)); }
/** * Create a zip file. * * @param destination * The zip file to create. * @param source * The file or directory to be zipped. * @throws FileNotFoundException * @throws IOException */ public static void zip(File destination, File source) throws FileNotFoundException, IOException { zip(destination, new File[] {source}); }
/** * Create a zip file. * * @param destination * The zip file to create. * @param source * The file or directory to be zipped. * @throws FileNotFoundException * @throws IOException */ public static void zip(File destination, File source) throws FileNotFoundException, IOException { zip(destination, new File[] {source}); }
public static void unzip(InputStream is, String destDir) throws FileNotFoundException, IOException { unzip(is, new File(destDir)); }
public static void zip(String destination, String source) throws FileNotFoundException, IOException { zip(new File(destination), new File(source)); }
private File stage(InputStream inputStream) throws IOException { File stagingDir = new File(installDir, "fedorawar"); stagingDir.mkdirs(); Zip.unzip(inputStream, stagingDir); return stagingDir; } private File repackage(File stagingDir, File outputFile) throws IOException {
public static void zip(String destination, String source) throws FileNotFoundException, IOException { zip(new File(destination), new File(source)); }
/** * Unpacks the contents of the FEDORA_HOME directory from the Distribution. * * @throws InstallationFailedException */ private void unpack() throws InstallationFailedException { System.out.println("Preparing FEDORA_HOME..."); if (!_installDir.exists() && !_installDir.mkdirs()) { throw new InstallationFailedException( "Unable to create FEDORA_HOME: " + _installDir.getAbsolutePath()); } if (!_installDir.isDirectory()) { throw new InstallationFailedException(_installDir.getAbsolutePath() + " is not a directory"); } try { Zip.unzip(_dist.get(Distribution.FEDORA_HOME), _installDir); setScriptsExecutable(new File(_installDir, "client" + File.separator + "bin")); File serverDir = new File(_installDir, "server"); if (_clientOnlyInstall) { FileUtils.delete(serverDir); } else { setScriptsExecutable(new File(serverDir, "bin")); } } catch (IOException e) { throw new InstallationFailedException(e.getMessage(), e); } }
private File repackage(File stagingDir, File outputFile) throws IOException { Zip.zip(outputFile, stagingDir.listFiles()); FileUtils.delete(stagingDir); return outputFile; } private void addLibrary(File stagingDir, String libraryPath,
@Override protected void installTomcat() throws InstallationFailedException { System.out.println("Installing Tomcat..."); try { Zip.unzip(getDist().get(Distribution.TOMCAT), System .getProperty("java.io.tmpdir")); } catch (IOException e) { throw new InstallationFailedException(e.getMessage(), e); } File f = new File(System.getProperty("java.io.tmpdir"), Distribution.TOMCAT_BASENAME); if (!FileUtils.move(f, getTomcatHome())) { throw new InstallationFailedException("Move to " + getTomcatHome().getAbsolutePath() + " failed."); } FedoraHome.setScriptsExecutable(new File(getTomcatHome(), "bin")); }
/** * Create a zip file. * * @param destination * The zip file to create. * @param source * The File array to be zipped. * @throws FileNotFoundException * @throws IOException */ public static void zip(File destination, File[] source) throws FileNotFoundException, IOException { FileOutputStream dest = new FileOutputStream(destination); ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(dest)); for (File element : source) { zip(null, element, zout); } zout.close(); }
@Test public void testUnzip() throws Exception { FileInputStream fis = new FileInputStream(ZIP_FILE); Zip.unzip(fis, TMP_DIR); FileReader fr = new FileReader(TMP_DIR + File.separator + "foo" + File.separator + "foo.txt"); BufferedReader buff = new BufferedReader(fr); boolean eof = false; while (!eof) { String line = buff.readLine(); if (line == null) { eof = true; } else { assertEquals("foo", line); } } buff.close(); } }
/** * Create a zip file. * * @param destination * The zip file to create. * @param source * The File array to be zipped. * @throws FileNotFoundException * @throws IOException */ public static void zip(File destination, File[] source) throws FileNotFoundException, IOException { FileOutputStream dest = new FileOutputStream(destination); ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(dest)); for (File element : source) { zip(null, element, zout); } zout.close(); }
File files[] = source.listFiles(); for (File element : files) { zip(entry.getName(), element, zout);
File files[] = source.listFiles(); for (File element : files) { zip(entry.getName(), element, zout);
@Test public void testZip() throws Exception { Zip.zip(ZIP_FILE, SRC_DIR.listFiles()); ZipFile zf = new ZipFile(ZIP_FILE); try { assertEquals(5, zf.size()); } finally { zf.close(); } }