00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.objectweb.jonas.common;
00029
00030 import java.io.File;
00031 import java.io.FileOutputStream;
00032 import java.io.InputStream;
00033 import java.io.IOException;
00034 import java.util.jar.JarFile;
00035 import java.util.jar.JarEntry;
00036
00041 public class JJarFile extends JarFile {
00042
00046 private static final int BUFFER_SIZE = 2048;
00047
00052 public JJarFile(File file) throws IOException {
00053 super(file);
00054 }
00055
00061 public JJarFile(File file, boolean verify) throws IOException {
00062 super(file, verify);
00063 }
00064
00071 public JJarFile(File file, boolean verify, int mode) throws IOException {
00072 super(file, verify, mode);
00073 }
00074
00079 public JJarFile(String name) throws IOException {
00080 super(name);
00081 }
00082
00088 public JJarFile(String name, boolean verify) throws IOException {
00089 super(name, verify);
00090 }
00091
00097 public void extract(JarEntry jEnt, String filename) throws IOException {
00098
00099 try {
00100
00101 FileOutputStream out = new FileOutputStream(filename);
00102 InputStream jis = this.getInputStream(jEnt);
00103 int n = 0;
00104 try {
00105
00106 byte buffer[] = new byte[BUFFER_SIZE];
00107
00108 while ((n = jis.read(buffer)) > 0) {
00109 out.write(buffer, 0, n);
00110 }
00111 } finally {
00112 out.close();
00113 jis.close();
00114 }
00115 } catch (IOException e) {
00116 throw new IOException("Error while uncompressing the file " + filename + ": " + e.getMessage());
00117 }
00118
00119 }
00120
00121 }