Mercurial > hg > thermostat-tools-eclipse
view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/Unzipper.java @ 136:31d0ab4467ad
Add an export wizard to export entire plugin
Introduce an export wizard that can export the entire plugin
projects into a Thermostat installation.
Add 'tags' to projects to keep track of what the root project (to
export) is.
There's barely any feedback for the export process right now. Errors
and issues are effectively ignored.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Thu, 05 Jun 2014 11:53:06 -0400 |
parents | |
children |
line wrap: on
line source
package com.redhat.thermostat.tools.eclipse.plugin; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Unzipper { public void unzip(ZipFile zipFile, File targetDirectory) throws IOException { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { continue; } File targetFile = new File(targetDirectory, entry.getName()); targetFile.getParentFile().mkdirs(); copyStream(zipFile.getInputStream(entry), new FileOutputStream(targetFile)); } } private void copyStream(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[1024]; try (InputStream in = new BufferedInputStream(input)) { try (OutputStream out = new BufferedOutputStream(output)) { int read = 0; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } } } }