Getting class byte from a jar file

R

Robert Mark Bram

Howdy All!

Is it possible to obtain the byte for an individual class in a jar file?

I know we can get the byte for any physical file, I also know we can
manipulate ZipEntry objects through a JarFile.

Maybe we somehow obtain class bytes from a ZipEntry?

Any thoughts would be appreciated!

Rob
:)
 
C

Chris Smith

Robert said:
Howdy All!

Is it possible to obtain the byte for an individual class in a jar file?

I know we can get the byte for any physical file, I also know we can
manipulate ZipEntry objects through a JarFile.

Maybe we somehow obtain class bytes from a ZipEntry?

By "class bytes" do you mean the bytecode for a class? If so, then yes
you can certainly get it by using the ZipEntry. Open the ZipInputStream
(or a subclass like JarInputStream), keep called getNextEntry() until
you see the one you want, and then read the binary class definition just
as you typically would from an InputStream.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top