【发布时间】:2016-03-02 07:09:22
【问题描述】:
我有包含不同文件夹、子文件夹和文件的 jar。
要列出和查看 jar 的内容,我可以使用 jar -tvf jar_name。
有没有办法 jar -tvf 或类似的其他命令只列出 jar 内容中的目录。
我看到 jar 有以下选项,但除了 -t 之外,我找不到可以帮助专门列出文件或文件夹的选项。使用 -t 选项不能一次性完成。
jar Options:
-c create new archive
-t list table of contents for archive
-x extract named (or all) files from archive
-u update existing archive
-v generate verbose output on standard output
-f specify archive file name
-m include manifest information from specified manifest file
-e specify application entry point for stand-alone application
bundled into an executable jar file
-0 store only; use no ZIP compression
-M do not create a manifest file for the entries
-i generate index information for the specified jar files
-C change to the specified directory and include the following file
我需要加载 jar 文件并以树形结构显示文件夹和文件。实现这种逻辑的最佳方法是什么。
【问题讨论】:
-
你想用java显示还是只用命令行显示?
-
我想在 shell 脚本和 bat 文件中使用该功能。
-
我已经编辑了我的答案,希望对您有所帮助
-
感谢它为我工作。