Here you can find the source of getInfo(String jarFileName)
Parameter | Description |
---|---|
jarFileName | file name of the jar file to get information |
public static void getInfo(String jarFileName) throws Exception
//package com.java2s; /*/*w w w.j a v a2 s .c o m*/ * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Copyright (C) 2006-2010 Adele Team/LIG/Grenoble University, France */ import java.util.Date; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class Main { /** * Util: gets information about the given jar file name * * @param jarFileName file name of the jar file to get information * @exception Exception an exception occurs */ public static void getInfo(String jarFileName) throws Exception { // Create a Jar file. JarFile jarFile = new JarFile(jarFileName); System.out.println("\n---------------------------------------------------------"); System.out.println("Information about the jar file: " + jarFileName); System.out.println("---------------------------------------------------------"); // Get all of the Jar entries. Enumeration jarEntries = jarFile.entries(); // Print out information. JarEntry currentJarEntry = null; while (jarEntries.hasMoreElements()) { currentJarEntry = (JarEntry) jarEntries.nextElement(); System.out.println(); if (currentJarEntry.isDirectory()) System.out.println("Directory = " + currentJarEntry.getName()); else System.out.println("File = " + currentJarEntry.getName()); System.out.println("\tcomment = " + currentJarEntry.getComment()); System.out.println("\ttime = " + new Date(currentJarEntry.getTime())); System.out.println("\tsize = " + currentJarEntry.getSize()); System.out.println("\tcompress size = " + currentJarEntry.getCompressedSize()); System.out.println("\tcrc = " + currentJarEntry.getCrc()); } // Fermeture du fichier jar jarFile.close(); } }