Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 8252 invoked by uid 2016); 1 Nov 1999 21:52:56 -0000 Delivered-To: apcore-jakarta-tomcat-cvs@apache.org Received: (qmail 8240 invoked by uid 259); 1 Nov 1999 21:52:55 -0000 Date: 1 Nov 1999 21:52:54 -0000 Message-ID: <19991101215254.8236.qmail@hyperreal.org> From: costin@hyperreal.org To: jakarta-tomcat-cvs@apache.org Subject: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util WARUtil.java costin 99/11/01 13:52:54 Modified: src/share/org/apache/tomcat/util WARUtil.java Log: Fix from matt@arcticmail.com. Added warning for un-war errors. Submitted by: "Matt Petteys" Reviewed by: costin@eng.sun.com Revision Changes Path 1.2 +27 -15 jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java Index: WARUtil.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WARUtil.java 1999/10/09 00:20:56 1.1 +++ WARUtil.java 1999/11/01 21:52:52 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java,v 1.1 1999/10/09 00:20:56 duncan Exp $ - * $Revision: 1.1 $ - * $Date: 1999/10/09 00:20:56 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java,v 1.2 1999/11/01 21:52:52 costin Exp $ + * $Revision: 1.2 $ + * $Date: 1999/11/01 21:52:52 $ * * ==================================================================== * @@ -71,6 +71,7 @@ import java.net.URL; import java.io.IOException; import java.net.MalformedURLException; +import java.io.FileNotFoundException; /** * @@ -78,6 +79,12 @@ */ public class WARUtil { + /** Expand a WAR/Jar file in a directory. + * @param dir destination directory + * @param war URL for the source WAR/JAR/ZIP file. Starting + * and ending "/" will be removed + * + */ public static void expand(File dir, URL war) throws MalformedURLException, IOException { String s = trim(war.getFile(), "/"); @@ -86,20 +93,25 @@ ZipEntry ze = null; while ((ze = zis.getNextEntry()) != null) { - File f = new File(dir, ze.getName()); + try { + File f = new File(dir, ze.getName()); - if (ze.isDirectory()) { - f.mkdirs(); - } else { - byte[] buffer = new byte[1024]; - int length = 0; - FileOutputStream fos = new FileOutputStream(f); - - while ((length = zis.read(buffer)) >= 0) { - fos.write(buffer, 0, length); + if (ze.isDirectory()) { + f.mkdirs(); + } else { + byte[] buffer = new byte[1024]; + int length = 0; + FileOutputStream fos = new FileOutputStream(f); + + while ((length = zis.read(buffer)) >= 0) { + fos.write(buffer, 0, length); + } + + fos.close(); } - - fos.close(); + } catch( FileNotFoundException ex ) { + // XXX replace with a call to log() when available + System.out.println("WARUtil: FileNotFoundException: " + ze.getName() + " / " + s ); } }