Androidは圧縮パッケージの内容のみを読み取る(中国語の文字化けしを解決)
今apache-ant-zipをダウンロードします.JArを自分のプロジェクトにインポート
apache-ant-zip.JArのアドレス:https://download.csdn.net/download/wshiyf/8993883?locationNum=13&fps=1
apache-ant-zip.JArのアドレス:https://download.csdn.net/download/wshiyf/8993883?locationNum=13&fps=1
/**
*
* zipFile folderPath .
*
* @param zipFile zip zip ,new file
* @param folderPath
* @throws IOException
*/
public static List getZipFileList(File zipFile, String folderPath) throws IOException {
ZipFile zf = null;
try {
List 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(" - " + entryName);
Log.d("zipFileUtil"," - " + entryName);
File decompressDirFile = new File(path);
if (!decompressDirFile.exists())
{
decompressDirFile.mkdirs();
}
} else
{
System.out.println(" - " + entryName);
Log.d("zipFileUtil"," - " + entryName);
mList.add(folderPath + "/" + entryName);
}
}
zf.close();
for (int i = 0; i < mList.size(); i++) {
Log.d("zipFileUtil====",mList.get(i));
}
return mList;
} catch (IOException ex) {
throw ex;
} finally {
if (null != zf) {
zf.close();
}
}
}