Android_Zip解壓縮工具,android_zip解壓縮

來源:互聯網
上載者:User

Android_Zip解壓縮工具,android_zip解壓縮

public class ZipUtil {public ZipUtil(){} /**      * DeCompress the ZIP to the path      * @param zipFileString  name of ZIP      * @param outPathString   path to be unZIP     * @throws Exception      */      public static void UnZipFolder(String zipFileString, String outPathString) throws Exception {          ZipInputStream inZip = new ZipInputStream(new FileInputStream(zipFileString));          ZipEntry zipEntry;          String szName = "";         System.out.println("start");        while ((zipEntry = inZip.getNextEntry()) != null) {                      szName = zipEntry.getName();              System.out.println(szName);            if (zipEntry.isDirectory()) {                  // get the folder name of the widget                  szName = szName.substring(0, szName.length() - 1);                  File folder = new File(outPathString + File.separator + szName);                  folder.mkdirs();              } else {                            File file = new File(outPathString + File.separator + szName);                  file.createNewFile();                  // get the output stream of the file                  FileOutputStream out = new FileOutputStream(file);                  int len;                  byte[] buffer = new byte[1024];                  // read (len) bytes into buffer                  while ((len = inZip.read(buffer)) != -1) {                      // write (len) byte from buffer at the position 0                      out.write(buffer, 0, len);                      out.flush();                  }                  out.close();              }          }        System.out.println("ssssss");        inZip.close();      }          /**      * Compress file and folder     * @param srcFileString   file or folder to be Compress     * @param zipFileString   the path name of result ZIP     * @throws Exception      */      public static void ZipFolder(String srcFileString, String zipFileString)throws Exception {          //create ZIP         ZipOutputStream outZip = new ZipOutputStream(new FileOutputStream(zipFileString));          //create the file         File file = new File(srcFileString);          //compress        ZipFiles(file.getParent()+File.separator, file.getName(), outZip);          //finish and close        outZip.finish();          outZip.close();      }        /**      * compress files     * @param folderString      * @param fileString      * @param zipOutputSteam      * @throws Exception      */      private static void ZipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam)throws Exception{          if(zipOutputSteam == null)          return;          File file = new File(folderString+fileString);          if (file.isFile()) {              ZipEntry zipEntry =  new ZipEntry(fileString);              FileInputStream inputStream = new FileInputStream(file);              zipOutputSteam.putNextEntry(zipEntry);              int len;              byte[] buffer = new byte[4096];               while((len=inputStream.read(buffer)) != -1)              {                  zipOutputSteam.write(buffer, 0, len);              }              zipOutputSteam.closeEntry();          }          else {              //folder            String fileList[] = file.list();              //no child file and compress              if (fileList.length <= 0) {                  ZipEntry zipEntry =  new ZipEntry(fileString+File.separator);                  zipOutputSteam.putNextEntry(zipEntry);                  zipOutputSteam.closeEntry();                              }              //child files and recursion              for (int i = 0; i < fileList.length; i++) {                  ZipFiles(folderString, fileString+java.io.File.separator+fileList[i], zipOutputSteam);              }//end of for          }        }    /**      * return the InputStream of file in the ZIP     * @param zipFileString  name of ZIP      * @param fileString     name of file in the ZIP      * @return InputStream      * @throws Exception      */      public static InputStream UpZip(String zipFileString, String fileString)throws Exception {          ZipFile zipFile = new ZipFile(zipFileString);          ZipEntry zipEntry = zipFile.getEntry(fileString);          return zipFile.getInputStream(zipEntry);      }      /**      * return files list(file and folder) in the ZIP     * @param zipFileString     ZIP name     * @param bContainFolder    contain folder or not     * @param bContainFile      contain file or not     * @return      * @throws Exception      */      public static List<File> GetFileList(String zipFileString, boolean bContainFolder, boolean bContainFile)throws Exception {          List<File> fileList = new ArrayList<File>();          ZipInputStream inZip = new ZipInputStream(new FileInputStream(zipFileString));          ZipEntry zipEntry;          String szName = "";          while ((zipEntry = inZip.getNextEntry()) != null) {              szName = zipEntry.getName();              if (zipEntry.isDirectory()) {                  // get the folder name of the widget                  szName = szName.substring(0, szName.length() - 1);                  File folder = new File(szName);                  if (bContainFolder) {                      fileList.add(folder);                  }                        } else {                  File file = new File(szName);                  if (bContainFile) {                      fileList.add(file);                  }              }          }        inZip.close();          return fileList;      }  }


android解壓縮軟體

重新下載個吧,推薦這兩個小弟用過的:超級解壓工具 apkok、壓縮大師 apkok,還不錯哦,你上 樂致網 就可以下載到了,裡面軟體豐富,種類齊全,下載免費,去逛逛咯
參考資料:樂致網
 
android解壓縮軟體哪個好用

一般都不會單獨的解壓縮軟體的吧。正常情況是系統檔案管理工具(比如說RE管理器)裡內建解壓縮功能。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.