Written a class with java.util.zip to create and read the ZIP file. Share it with everyone. Take a recursive call. Heha has been used for a lot of recursive calls! Summary! / ** Testzip.java coding by serol luo. Rollingpig@163.com 2003/07/03 http://www.chinaUnix.net/forum/viewforum.php?f=26 Reprints Please keep this information * / Import Java. util *;. import java.util.zip *;. import java.io. *; class TestZip {public void zip (String zipFileName, String inputFile) throws Exception {zip (zipFileName, new File (inputFile));} public void zip (String zipFileName, File inputFile) throws Exception {ZipOutputStream out = new ZipOutputStream (new FileOutputStream (zipFileName)); zip (out, inputFile, ""); System.out.println ( "zip done"); out.close ( );} public void unzip (String zipFileName, String outputDirectory) throws Exception {ZipInputStream in = new ZipInputStream (new FileInputStream (zipFileName)); ZipEntry z;! while ((z = in.getNextEntry ()) = null) {System. Out.println ("unziping" z.getName ()); if (z.Indirectory ()) {string name = z.getname (); name = name.substring (0, name.length () - 1); File f = new file (OutputDirectory File.seParetor Name); f.mkdir (); System.out.Println ("MKDir" OutputDirectory File.seParetor Name); } else {file f = new file (OutputDirectory file.seParetor z.getname ()); f.createNewFile (); fileoutputstream out = new fileoutputstream (f); int b; while ((b = in.read () )! = -1) Out.write (b); out.close ();}} in.close ();} public void zip (zipoutputstream out, file f, string base) throws exception {system.out.println "Zipping" f.getname ()); if (f.Indirectory ()) {file [] fl = f.ListFiles (); out.putnextentry (new zipentry); base = base.length () == 0? "": Base "/"; for (int i = 0; i i ) {zip (out, fl [i], base fl [i] .getname ());}}} else {out.putNextentry (new zipentry (base)); fileInputstream in = new fileInputstream (f); int b WHILE ((b = in.read ())! = -1) Out.write (b); in .close ();}} public static void main (string [] args) {TRY {testzip t = new testzip (); T.ZIP ("C: //test.zip", "C: // Test"); T. Enzip ("C: //Test.zip", "C: // Test2"); Catch (Exception E) {E.PrintStackTrace (System.out);}}}