1 8 package org.apache.avalon.excalibur.vfs; 9 10 import java.io.InputStream ; 11 import java.util.zip.ZipFile ; 12 import java.util.zip.ZipEntry ; 13 14 19 public final class ZipVFileAccessor 20 implements VFileAccessor 21 { 22 28 public long getSize( final VFile file, final Object resource ) 29 { 30 try 31 { 32 final ZipFile zipFile = (ZipFile )resource; 33 final String name = file.toString().substring( 1 ); 34 final ZipEntry entry = zipFile.getEntry( name ); 35 return entry.getSize(); 36 } 37 catch( final Exception e ) 38 { 39 return -1; 40 } 41 } 42 43 50 public InputStream getInputStream( final VFile file, final Object resource ) 51 { 52 try 53 { 54 final ZipFile zipFile = (ZipFile )resource; 55 final String name = file.toString().substring( 1 ); 56 final ZipEntry entry = zipFile.getEntry( name ); 57 return zipFile.getInputStream( entry ); 58 } 59 catch( final Exception e ) 60 { 61 return null; 62 } 63 } 64 } 65 | Popular Tags |