import java.io.*; import java.util.jar.*; import java.util.zip.*; /** * @version 1.0 2002-04-29 * @author Takashi KOBAYASHI */ public class ex1 { static String filename = "jis.jar"; static String readentry = "jarscape.java"; public static void main( String[] args ) { try { JarInputStream jis = new JarInputStream( new BufferedInputStream( new FileInputStream( filename ) ) ); JarEntry je; while( ( je = jis.getNextJarEntry() ) != null ) { System.out.println( je.getName() ); if( je.getName().equals( readentry ) ) { int len; int bufsize = 1024; byte[] buf = new byte[bufsize]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while( jis.available() > 0 && ( len = jis.read( buf, 0, bufsize ) ) != -1 ) { baos.write( buf, 0, len ); } System.out.println( baos.toString() ); } } } catch( IOException ioe ) { ioe.printStackTrace(); } } }