- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
作为免责声明,我已经看过 this帖子和链接到它的帖子。
我在服务器上托管了一个文件,该文件是 n 个归档文件,我正尝试使用 this 取消归档它。方法。当文件被预先下载到设备上并且我在我的应用程序中打开并取消存档时,通过 Downloads
中的 intent-filter
,没有任何问题。但是,当我从我的应用程序中的服务器下载它,然后尝试解压缩它时,我在这一行的标题中收到错误消息:
ZipFile zipfile = new ZipFile(archive);
其中 archive
是一个 File
指向我下载的存档文件。我用来下载存档的代码如下:
String urlPath = parameters[0], localPath = parameters[1];
try
{
URL url = new URL(urlPath);
URLConnection connection = url.openConnection();
connection.addRequestProperty("Accept-Encoding", "gzip");
connection.connect();
int fileLength = connection.getContentLength();
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new BufferedOutputStream(new FileOutputStream(localPath));
byte data[] = new byte[1024];
long total = 0;
int count;
while((count = input.read(data)) != -1)
{
total += count;
publishProgress((int)total * 100 / fileLength);
output.write(data);
}
output.flush();
output.close();
input.close();
我最近根据我在顶部引用的帖子添加了编码类型,但我仍然遇到相同的错误。任何帮助都会很棒。
澄清一下:
java.util.zip.ZipException: Central Directory Entry not found
我最好的猜测是这是我下载的问题。但是,话虽如此,我不知道自己做错了什么。
最佳答案
您没有正确复制下载内容。你必须使用
output.write(data, 0, count);
否则你就是在向文件中写入任意垃圾。
关于java - 还是个问题? - java.util.zip.ZipException : Central Directory Entry not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14655689/
我只想提取一个普通的 zip 文件,但它总是失败。这是我现在使用的代码: private File downloadPath = new File(Environment.getExternalSto
我正在使用Firebase和API.AI开发Android聊天机器人应用程序。 将firebase UI库添加到项目后,我得到了 java.util.zip.ZipException:重复条目运行时异
我正在更新版本 3.4 的 Android studio 和插件(版本 5.1.1 的 gradle)当我尝试构建项目时,出现错误 java.util.zip.ZipException: zip fi
我遇到以下异常 java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Nati
我正在尝试将 zip 文件下载到 SD 卡。我正确下载了它,但是当我打开下载的文件(使用 ZipFile)时,我得到了这个 ZipException(“找不到中央目录条目”)。 Internet 文件
从今天早上开始(我更新了一些插件,并更新了 mac os X),每当系统想要读取 jar/zip 文件时,我都会收到 ZipException。起初我以为这是新版本插件中的一个错误,但它似乎是相当低级
这个问题在这里已经有了答案: Invalid Entry Compressed Size (2 个答案) 关闭 9 年前。 我正在尝试创建一种方法,只需一个步骤即可将多个 zip 存档相互融合。该代
我使用 Tomcat 8 和此类 Jersey 的动态 Web 项目依赖项。 com.sun.jersey jersey-client
我正在尝试将MoPub集成到我的应用程序中。 我将SDK导入了我的应用程序: compile('com.mopub.sdk.android:mopub:4.4.1@aar') { transi
Server: jboss-5.1.0 Java Version: jdk1.6.0_14 Deployment Method: ant v1.7 Error: 08:40:04,260 WARN [
我从事 Java 编程已有大约 15 年了。虽然这是一个基本问题,但这并不是因为故意无视 Java API 或阅读文档。坦率地说,我真的很震惊,我遇到了一种情况,我无法使用命令行工具创建一个简单的 j
我正在构建一个项目,其中有两个类(A 和 B)都继承自 BaseClass。 A 和 B 两个类都有 @Parceler 注释。当我为操作系统版本 4.1.2 (API 16) 的手机构建它时,它给了
我正在尝试使用以下命令更新现有 jar(在此示例中为 antlr)中的文件: jar -uf antlrworks-1.2.3.jar org/antlr/codegen/templates/Java
我一直在尝试让 ant 执行一些用 junit 编写的测试,但没有成功。任何建议将不胜感激。我对 ant 和 Java 都很陌生,所以请耐心等待。 作为快速总结,我正在做的是尝试让 ant 执行一个非
我正在将应用程序从 2.3 升级到 Nougat (SDK 25)。当我添加 com.android.support:appcompat-v7:25.0.0 以支持 ActivityCompat.re
这个问题在这里已经有了答案: How to resolve java.util.zip.ZipException? (11 个答案) 关闭 7 年前。 我正在尝试使用新的 multidex 选项,但
我对使用 Java 处理 zip 文件完全陌生,我遇到了一个奇怪的情况。 这是我用来解压的方法: public void unzip(File zipFile, File rootDir) throw
我在我的 Android 应用程序中使用 EBS 支付网关。 EBS 在其文件夹中包含 volley 库。我还为我的项目使用了 volley 库。所以我得到了这样的异常。 Execution fail
本文整理了Java中java.util.zip.ZipException.getLocalizedMessage()方法的一些代码示例,展示了ZipException.getLocalizedMess
本文整理了Java中java.util.zip.ZipException.()方法的一些代码示例,展示了ZipException.()的具体用法。这些代码示例主要来源于Github/Stackover
我是一名优秀的程序员,十分优秀!