Read the Entries from a JAR/ZIP Archives with the URL Class

Read the Entries from a JAR/ZIP Archives with the URL Class

This tip shows you how to display the entries from a JAR/ZIP archive using the class. The key in this example is the URL construction.

import*;import*;import java.awt.*;import java.util.*;import java.util.jar.*;class read extends Frame{   URL url=null;   JarURLConnection URLcon=null;   JarFile jar=null;   TextArea TA=new TextArea(15,35);   public read(String titlu)   {      super(titlu);   }   void init()   {      setLayout(new FlowLayout());      setSize(300,300);      add(TA);      setVisible(true);   }   public void getURLContent()   {         try      {                   //local archive         url=new URL("jar:file:/C:/Program%                              20Files/Java/jdk1.5.0/jre/lib/jsse.jar!/");         //remote archive         //url=new URL("jar:http://.../archive.jar!/");                         URLcon=(JarURLConnection)(url.openConnection());         jar=URLcon.getJarFile();      }      catch(MalformedURLException e)      {         System.out.println("Eroare1:"+e.getMessage());      }      catch(IOException e)      {         System.out.println("Eroare2:"+e.getMessage());      }   }              void entry()   {      Enumeration  entries=jar.entries();      while(entries.hasMoreElements())      {         String entry=((JarEntry)entries.nextElement()).getName();         TA.append(entry+"
");      }     }}public class JarURLContent{   public static void main(String[] args)   {      read t=new read("URL");            t.getURLContent();      t.init();          t.entry();     }}
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular