List of usage examples for org.apache.commons.compress.archivers.jar JarArchiveInputStream read
public int read(byte b[]) throws IOException
b
. From source file:es.jamisoft.comun.utils.compression.Jar.java
private void unjar(InputStream is, String outputDirectory) throws IOException { JarArchiveInputStream jis = new JarArchiveInputStream(is); JarArchiveEntry jarEntry = null;//from w w w .j a v a2s . co m byte buffer[] = new byte[1024]; int readCount = 0; if (!outputDirectory.endsWith(File.separator)) { outputDirectory = outputDirectory + File.separator; } do { if ((jarEntry = jis.getNextJarEntry()) == null) { break; } if (jarEntry.isDirectory()) { File file = new File(outputDirectory + jarEntry.getName()); if (!file.exists()) { file.mkdir(); } } else { FileOutputStream fos = new FileOutputStream(outputDirectory + jarEntry.getName()); while ((readCount = jis.read(buffer)) != -1) { fos.write(buffer, 0, readCount); } fos.close(); } } while (true); jis.close(); }