android - 通过 NodeJS Express 发送 epub 文件
问题描述
我正在尝试将一个 zip 文件从 nodeJs 发送到 android,我使用以下方法在 android 中解压缩它:
public void unzip(String zipFile, String location) throws IOException {
try {
File f = new File(location);
if (!f.isDirectory()) {
f.mkdirs();
}
ZipInputStream zin = new ZipInputStream(new FileInputStream(zipFile));
try {
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
String path = location + File.separator + ze.getName();
System.out.println(path);
if (ze.isDirectory()) {
File unzipFile = new File(path);
if (!unzipFile.isDirectory()) {
unzipFile.mkdirs();
}
} else {
FileOutputStream fout = new FileOutputStream(path, false);
try {
for (int c = zin.read(); c != -1; c = zin.read()) {
fout.write(c);
}
zin.closeEntry();
} finally {
fout.close();
}
}
}
} finally {
zin.close();
}
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "Unzip exception", e);
}
}
它给了我一个例外:
E/EXCEPTION: Unzip exception
java.io.EOFException: Unexpected end of ZLIB input stream
zip 文件包含 .opf、.ncx 和 .xml 文件。谁能帮忙
解决方案
推荐阅读
- java - 使用连接池使用 JUnit 对 DAO 类进行单元测试
- laravel - Laravel 8 - Payumoney 集成成功页面问题
- javascript - 如何在 HTML 中执行 Electron js 命令?
- python - 如何在我的 django 项目的 settings.py 文件中将我的身份验证后端设置为默认值(扩展 AbstractBaseUser 模型)
- python - 尝试在不使用函数的情况下检查输入中是否有任何大写、小写、非字母字母,但代码不起作用
- html - 如何在元素面板中搜索?
- c++ - 为什么在传递给异步时从默认构造函数调用移动构造函数?
- python - VGG16 模型总是预测第一类
- javascript - 如何将所有css文件包含在文件夹中?
- azure - Azure 流分析过滤多个输入列以输出到 SQL 表,卡在 5 个接收器的限制