日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android 解压中文乱码(压缩包内中文乱码)

發(fā)布時間:2024/3/26 Android 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android 解压中文乱码(压缩包内中文乱码) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

首先下載apache-ant-zip.jar,導(dǎo)入到自己的項目中

apache-ant-zip.jar的地址:https://download.csdn.net/download/wshiyf/8993883?locationNum=13&fps=1

之后就是代碼:

?

/*** 解壓縮* 將zipFile文件解壓到folderPath目錄下.** @param zipFile zip文件所在的地址,new成file* @param folderPath 解壓到的地址* @throws IOException*/ public static void upZipFile(File zipFile, String folderPath) throws IOException {ZipFile zf = null;BufferedOutputStream bos=null;BufferedInputStream bi = null;try {List<String> mList = new ArrayList<>();zf = new ZipFile(zipFile, "GBK");Enumeration e = zf.getEntries();while (e.hasMoreElements()){ZipEntry ze2 = (ZipEntry) e.nextElement();String entryName = ze2.getName();String path = folderPath + "/" + entryName;if (ze2.isDirectory()){System.out.println("正在創(chuàng)建解壓目錄 - " + entryName);Log.d("zipFileUtil","正在創(chuàng)建解壓目錄 - " + entryName);File decompressDirFile = new File(path);if (!decompressDirFile.exists()){decompressDirFile.mkdirs();}} else{System.out.println("正在創(chuàng)建解壓文件 - " + entryName);Log.d("zipFileUtil","正在創(chuàng)建解壓文件 - " + entryName);mList.add(folderPath + "/" + entryName);String fileDir = path.substring(0, path.lastIndexOf("/"));File fileDirFile = new File(fileDir);if (!fileDirFile.exists()){fileDirFile.mkdirs();}bos = new BufferedOutputStream(new FileOutputStream(folderPath + "/" + entryName));bi = new BufferedInputStream(zf.getInputStream(ze2));byte[] readContent = new byte[1024];int readCount = bi.read(readContent);while (readCount != -1){bos.write(readContent, 0, readCount);readCount = bi.read(readContent);}bos.close();}}zf.close();for (int i = 0; i < mList.size(); i++) {Log.d("zipFileUtil====",mList.get(i));}} catch (IOException ex) {throw ex;} finally {if (null != zf) {zf.close();}if (null != bi) {bi.close();}if (null != bos) {bos.close();}}}

?

總結(jié)

以上是生活随笔為你收集整理的Android 解压中文乱码(压缩包内中文乱码)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。