开发者

How to find the package of a class file in java

开发者 https://www.devze.com 2023-04-04 11:40 出处:网络
I\'m writing a java program that works with .class files. I want to be able to read a .class file on the filesystem (开发者_JAVA技巧with InputStream) and determine the package that it is in. That .cla

I'm writing a java program that works with .class files. I want to be able to read a .class file on the filesystem (开发者_JAVA技巧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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号