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);
            
        }

    }
  • 相关阅读:
    iOS开发之JSON格式数据的生成与解析
    Xcode 怎么查看代码总行数
    iOS OC与JS的交互(JavaScriptCore实现)
    Webstorm设置代码提示
    iOS app性能优化的那些事
    pThread多线程demo
    更新UI放在主线程的原因
    iOS小知识点
    上传本地代码及更新代码到GitHub教程
    logstash安装配置
  • 原文地址:https://www.cnblogs.com/jifeng/p/2280783.html
Copyright © 2011-2022 走看看