Hi, I need a way to get class files (File objects) from a JAR file (unknown JAR file).
I know that you cant acutally get the File objects from the JAR itself (only get inputstreams from each entry). So i guess i need a way to use the input stream to create a temp file that is the actual .class file so I can get a File object for it.
Once i have this i can use it as I want then delete it and go to the next one.
I dont know if there is an easier or more efficient way?
The reason I need the actual File object is that im using a Library that requires a File object of a class file to do its function.
Anyways I have the incomplete code here:
So im looking for some help on how to create a file, THen i guess read in the bytes from the InputStream and write them out to the new file. Is this possible? Please any help would be great.Code:Enumeration <JarEntry> e; JarFile jf = new JarFile("C:\\ToDoList_1.0.0.jar"); jffp.setJarName(jf.getName()); e = jf.entries(); while(e.hasMoreElements()){ JarEntry entry = new JarEntry(e.nextElement()); String name = entry.getName(); if((name.length() >4) && (name.substring(name.length()-5, name.length()).equalsIgnoreCase("class"))){ InputStream input = jf.getInputStream(entry); . . .


Reply With Quote


Bookmarks