StaticWeaveDirectoryOutputHandlerpublic class StaticWeaveDirectoryOutputHandler extends AbstractStaticWeaveOutputHandler The class provides a set of methods to pack passed-in entries into the sepcified archive file.
the class handle directory output. |
Fields Summary |
---|
private URL | source | private URL | target |
Constructors Summary |
---|
public StaticWeaveDirectoryOutputHandler(URL source, URL target)Construct an instance of StaticWeaveDirectoryOutputHandler.
this.source=source;
this.target=target;
|
Methods Summary |
---|
public void | addDirEntry(java.lang.String dirPath)create directory into target directory.
File file = new File(this.target.getPath()+File.separator+dirPath).getAbsoluteFile();
if (!file.exists()){
file.mkdirs();
}
| public void | addEntry(java.util.jar.JarEntry targetEntry, byte[] entryBytes)Write entry bytes into target, this method is usually invoked if class has been tranformed
File target = new File(this.target.getPath()+targetEntry.getName()).getAbsoluteFile();
if(!target.exists()) {
target.createNewFile();
}
(new FileOutputStream(target)).write(entryBytes);
| public void | addEntry(java.io.InputStream jis, java.util.jar.JarEntry entry)Write entry into target, this method usually copy original class into target.
File target = new File(this.target.getPath()+entry.getName()).getAbsoluteFile();
if(!target.exists()) {
target.createNewFile();
}
if((new File(this.source.toURI())).isDirectory()){
File sourceEntry = new File(this.source.getPath()+entry.getName());
FileInputStream fis = new FileInputStream(sourceEntry);
byte[] classBytes = new byte[fis.available()];
fis.read(classBytes);
(new FileOutputStream(target)).write(classBytes);
}else{
readwriteStreams(jis,(new FileOutputStream(target)));
}
|
|