Hi,
The following is a not solution for you, but is a good tip for anyone
wanting to unzip files....:
Handling Zip files with Java is difficult. Many Specifications are poor
and loose (including the 'zip' spec), and implementations will therefore
vary, making interoperability difficult.
You can quickly get your hands on excellent functionality by
programmatically calling Jakarta Ant tasks (!), and reuse their well
tested and robust code. This is how one can unzip a zip file.
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.taskdefs.Expand;
/**
* uses jakarta ANT to unzip
* @param zipFilepath
* @param destinationDir
* @throws ZipException
* @throws Exception
*/
static public void unzip(String zipFilepath, String
destinationDir)throws ZipException, Exception {
try{
final class Expander extends Expand {
public Expander() {
project = new Project();
project.init();
taskType = "unzip";
taskName = "unzip";
target = new Target();
}
}
Expander expander = new Expander();
expander.setSrc(new File(zipFilepath));
expander.setDest(new File(destinationDir));
expander.execute();
} catch (Exception e){
throw new Exception("Zip - unzip - ["
+e.getMessage() + "]");
}
}
Of course the Ant jar file has to be included on the classpath.
If you have not already done it, study all the available Ant targets,
and when applicable, programmatically call Ant tasks to solve your
problem.
Dui ni de wenti lai jiang, keneng you qitade Ant tasks....
Regards
Jon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]