JJarFile.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * Initial developer(s): Eric HARDESTY
00022  * --------------------------------------------------------------------------
00023  * $Id: JJarFile.java,v 1.0
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             //File output
00101             FileOutputStream out = new FileOutputStream(filename);
00102             InputStream jis = this.getInputStream(jEnt);
00103             int n = 0;
00104             try {
00105                 //buffer
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 }

Generated on Tue Feb 15 15:05:14 2005 for JOnAS by  doxygen 1.3.9.1