Getting a directory inside a .jar

后端 未结 8 1488
悲哀的现实
悲哀的现实 2020-12-11 04:48

I am trying to access a directory inside my jar file. I want to go through every of the files inside the directory itself. I tried, for example, using the following:

<
8条回答
  •  北海茫月
    2020-12-11 05:02

    If I understand your problem you want to check the directory inside the jar and check all the files inside that directory.You can do something like:

    JarInputStream jar = new JarInputStream(new FileInputStream("D:\\x.jar"));
        JarEntry jarEntry ;
        while(true)
            {
             jarEntry = jar.getNextJarEntry();
             if(jarEntry != null)
             {
    
                if(jarEntry.isDirectory() == false)
                {
            String str = jarEntry.getName();
                    if(str.startsWith("weblogic/xml/saaj"))
            {
                anything which comes here are inside weblogic\xml\saaj directory
            }
            }
    
         }
        }    
    

提交回复
热议问题