How to find the package of a class file in java

2019-02-20 21:33发布

I'm writing a java program that works with .class files. I want to be able to read a .class file on the filesystem (with InputStream) and determine the package that it is in. That .class file might not be in a nice package directory structure, it could be lying around in some random place. How can I do this?

1条回答
霸刀☆藐视天下
2楼-- · 2019-02-20 22:05

Read the class file format documentation - or use a library which knows how to parse class files, such as BCEL and its ClassParser class.

查看更多
登录 后发表回答