zoukankan      html  css  js  c++  java
  • java 获取jar包路径,遍历jar包

    package cn.net.comsys.mdd.eclipse.plugin.j2eedt.core.javaee_5_container.librarymgmt;

    import java.io.IOException;
    import java.net.URL;
    import java.net.URLDecoder;
    import java.util.Enumeration;
    import java.util.jar.JarEntry;
    import java.util.jar.JarFile;



    import com.genuitec.eclipse.j2eedt.taglib.DirTaglibInfo;

    public class T {
    public static void main(String[] args) throws IOException {
            
        URL url = DirTaglibInfo.class.getProtectionDomain().getCodeSource().getLocation();
        String filePath = URLDecoder.decode(url.getPath(), "UTF-8");
        if(filePath.endsWith(".jar"))
        System.out.println(filePath);
        
            //java.util.jar.JarFile file = new JarFile("E:\\frame\\jdbc\\mysql.jar");
        java.util.jar.JarFile file = new JarFile(filePath);
            Enumeration<JarEntry> entrys = file.entries();
            while(entrys.hasMoreElements()){
                JarEntry jar = entrys.nextElement();
                System.out.println(jar.getName());
            }
            
            
            file.close();
            
            
            
          //filePath= filePath.substring(0, filePath.lastIndexOf("/") + 1);
            
        }

    }
  • 相关阅读:
    JavaScript (三) js的基本语法
    JavaScript (二) js的基本语法
    JavaScript (一) js的介绍及基本语法变量
    Spring事务管理
    python静态方法、类方法
    python多继承
    python面向对象
    python模块(4)
    python模块(3)
    python模块(2)
  • 原文地址:https://www.cnblogs.com/jifeng/p/2280783.html
Copyright © 2011-2022 走看看