1 26 27 28 package org.objectweb.jonas.common; 29 30 import java.io.File ; 31 import java.io.FileOutputStream ; 32 import java.io.InputStream ; 33 import java.io.IOException ; 34 import java.util.jar.JarFile ; 35 import java.util.jar.JarEntry ; 36 37 41 public class JJarFile extends JarFile { 42 43 46 private static final int BUFFER_SIZE = 2048; 47 48 52 public JJarFile(File file) throws IOException { 53 super(file); 54 } 55 56 61 public JJarFile(File file, boolean verify) throws IOException { 62 super(file, verify); 63 } 64 65 71 public JJarFile(File file, boolean verify, int mode) throws IOException { 72 super(file, verify, mode); 73 } 74 75 79 public JJarFile(String name) throws IOException { 80 super(name); 81 } 82 83 88 public JJarFile(String name, boolean verify) throws IOException { 89 super(name, verify); 90 } 91 92 97 public void extract(JarEntry jEnt, String filename) throws IOException { 98 99 try { 100 FileOutputStream out = new FileOutputStream (filename); 102 InputStream jis = this.getInputStream(jEnt); 103 int n = 0; 104 try { 105 byte buffer[] = new byte[BUFFER_SIZE]; 107 108 while ((n = jis.read(buffer)) > 0) { 109 out.write(buffer, 0, n); 110 } 111 } finally { 112 out.close(); 113 jis.close(); 114 } 115 } catch (IOException e) { 116 throw new IOException ("Error while uncompressing the file " + filename + ": " + e.getMessage()); 117 } 118 119 } 120 121 } 122 | Popular Tags |