/**
* 读取zip包里的文件(不需要解压zip)
*
* @param zipFile zip包
* @param readFileName 需要读取的文件名
* @return 读取结果
* @throws Exception
*/
public static String readZipFile(File zipFile,String readFileName)throws Exception {
ZipFile zf =new ZipFile(zipFile);
InputStream in =new BufferedInputStream(new FileInputStream(zipFile));
ZipInputStream zin =new ZipInputStream(in);
ZipEntry ze;
String mFileData ="";
String line ="";
while ((ze =zin.getNextEntry()) !=null) {
if (!ze.isDirectory()) {
RYLogUtils.d(TAG,"file - " +ze.getName());
if (ze.getName().contains(readFileName)) {
BufferedReader br =new BufferedReader(
new InputStreamReader(zf.getInputStream(ze)));
while ((line =br.readLine()) !=null) {
RYLogUtils.d(TAG,line);
mFileData =line;
}
br.close();
}
}
}
zin.closeEntry();
in.close();
return mFileData;
}
网友评论