Coverage Report - org.codehaus.plexus.compiler.csharp.JarUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
JarUtil
0%
0/18
0%
0/6
4
 
 1  
 package org.codehaus.plexus.compiler.csharp;
 2  
 
 3  
 import java.io.File;
 4  
 import java.io.FileOutputStream;
 5  
 import java.io.IOException;
 6  
 import java.io.InputStream;
 7  
 import java.util.Enumeration;
 8  
 import java.util.jar.JarEntry;
 9  
 import java.util.jar.JarFile;
 10  
 
 11  0
 public class JarUtil {
 12  
     public static void extract( File destDir, File jarFile ) throws IOException
 13  
     {
 14  0
         JarFile jar = new JarFile( jarFile );
 15  0
         Enumeration enumEntries = jar.entries();
 16  0
         while ( enumEntries.hasMoreElements() ) {
 17  0
             JarEntry file = ( JarEntry ) enumEntries.nextElement();
 18  0
             File f = new File( destDir + File.separator + file.getName() );
 19  0
             if ( file.isDirectory() )
 20  
             {
 21  0
                 f.mkdir();
 22  0
                 continue;
 23  
             }
 24  0
             InputStream is = jar.getInputStream( file );
 25  0
             FileOutputStream fos = new FileOutputStream( f );
 26  
             try
 27  
             {
 28  0
                 while ( is.available() > 0 )
 29  
                 {
 30  0
                     fos.write( is.read() );
 31  
                 }
 32  
             }
 33  
             finally
 34  
             {
 35  0
                 is.close();
 36  0
                 fos.close();
 37  0
             }
 38  0
         }
 39  0
     }
 40  
 }