How to list the files inside a JAR file?

前端 未结 16 2242
温柔的废话
温柔的废话 2020-11-22 00:40

I have this code which reads all the files from a directory.

    File textFolder = new File(\"text_directory\");

    File [] texFiles = textFolder.listFiles         


        
16条回答
  •  花落未央
    2020-11-22 01:31

    Just a different way of listing/reading files from a jar URL and it does it recursively for nested jars

    https://gist.github.com/trung/2cd90faab7f75b3bcbaa

    URL urlResource = Thead.currentThread().getContextClassLoader().getResource("foo");
    JarReader.read(urlResource, new InputStreamCallback() {
        @Override
        public void onFile(String name, InputStream is) throws IOException {
            // got file name and content stream 
        }
    });
    

提交回复
热议问题