Handling JAR files in the app

xiaoxiao2021-03-06  53

The purpose of this paper is to tell how to process JAR files through the program, which is relatively large to operate the JAR file in the command line or IDE. The content we mainly involved is the use of java.util.jar bags and java.io packages.

Many developers are not familiar with java.util.jar package, so the article will mainly tell the 8 classes, where Jarfile and Jarentry are core classes, which represent the JAR files and file entities in the JAR file, respectively. Usually we can build an instance of JARFILE by following the following method. After the JARFILE is referenced, we can process it. JARFILE (File File) JARFILE (File File, Boolean Verify) JARFile (String Name) JARFile (String Name, Boolean Verify) You can build JARFILE using the file object or String type file name. For example, Jarfile Jarfile = New Jarfile ("J2ME.jar"); After you get this reference, we can call the Jarfile.Entries () method to return to the jarentry object's enumeration. This way we can do him. First we write a program to browse the content in the JAR file. Import java.io. *; import java.util. *; Import java.util.jar. *;

Public class listjar {public static void main (string args []) {for (int i = 0, n = args.length; i

Private static void listjar (String Name) throws oException {system.out.println ("jar:" name); jarfile jar = new jarfile (name); enumeration E = jar.entries (); while (E.hasMoreElements () ) {Listinfo ((jarentry) E.NEXTELEMENT ());} system.out.println ();

转载请注明原文地址:https://www.9cbs.com/read-116501.html

New Post(0)