前文描述:
之前公司有一个 .exe 的工具:A:可以把一个文件放进压缩包,B:可以检验被放进压缩包的文件。
现在需要用Java编写一个类似的工具。
1、工具写好之后进行验证时发现:
1)用java代码工具进行AB操作时完全正常。
2)用java代码工具进行A操作用exe工具进行B操作正常。
3)用exe工具进行A操作,用java工具进行B操作抛出异常。异常如下:
: invalid entry size (expected 67324752 but got 5896 bytes)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (:127)
at (:86)
at (:72)
at (Unknown Source)
at $(Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at $400(Unknown Source)
at $(Unknown Source)
at $(Unknown Source)
at (Native Method)
at $(Unknown Source)
at $(Unknown Source)
at $(Unknown Source)
at $(Unknown Source)
at (Native Method)
at $(Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
2、问题详细信息:
exe进行A操作的代码:
//拷贝zip文件
string tmpZipPath = zipFolder + "\\" + mark + "_" + zipFileName;
(zipPath, tmpApkPath, true);
//将mark对应到文件添加到apk
using ( zip = new (tmpZipPath))
{
();
(markPath, "META-INF\\" + markEnc);
();
();
}
java工具进行B操作的代码:
ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
ZipEntry entry = null;
while((entry = ()) != null){
String entryName = ();
if((ChannelUtil.CHANNEL_DIR+ChannelUtil.MARK_FILE_MARKS)){
break;
}
}
();
();
3.解决办法:
java工具进行B操作的代码修改为:
ZipFile zipFile = new ZipFile(file);
Enumeration<? extends ZipEntry> enumeration= ();
while(()){
String entryName = ().getName();
if((ChannelUtil.CHANNEL_DIR+ChannelUtil.MARK_FILE_MARKS)){
break;
}
}
();