Java decompress a file and java decompress the file
/*** Decompress a file ** @ param zipFile * compressed file * @ param folderPath * decompressed target directory * @ throws IOException * thrown when an error occurs during the decompression */public static void unZipFile (File zipFile, string folderPath) throws ZipException, IOException {String sub = zipFile. getName (); int pos = sub. lastIndexOf (". "); if (pos> = 0) {sub = sub. substring (0, pos);} File subDir = new File (folderPath + File. separator + sub); if (subDir. exists () {d EleteFile (subDir);} subDir. mkdirs (); ZipFile zf = new ZipFile (zipFile); for (Enumeration <?> Entries = zf. entries (); entries. hasMoreElements ();) {ZipEntry entry = (ZipEntry) entries. nextElement (); InputStream in = zf. getInputStream (entry); String str = subDir. getAbsolutePath () + File. separator + entry. getName (); // str = new String (str. getBytes ("8859_1"), "UTF-8"); File desFile = new File (str); if (! DesFile. exists () {File fileParentDir = desFile. getParentFile (); if (! FileParentDir. exists () {fileParentDir. mkdirs ();} if (entry. isDirectory () {desFile. mkdirs (); continue;} desFile. createNewFile ();} OutputStream out = new FileOutputStream (desFile); byte buffer [] = new byte [10240]; int realLength; while (realLength = in. read (buffer)> 0) {out. write (buffer, 0, realLength);} in. close (); out. close ();} zf. close ();} private static void deleteFile (File file ){ If (file. isDirectory () {File [] fs = file. listFiles (); if (fs! = Null) {for (File f: fs) {deleteFile (f) ;}} file. delete ();}