Java /_rels/.rels:open失败:enoint(没有这样的文件或目录)
当我试图解压一个.xlsx文件时,我在标题中看到了一个错误。我在清单中有写权限。它解压第一个文件fine[Content\u Types].xml,但无法解压其他文件 这是我的解压码Java /_rels/.rels:open失败:enoint(没有这样的文件或目录),java,android,Java,Android,当我试图解压一个.xlsx文件时,我在标题中看到了一个错误。我在清单中有写权限。它解压第一个文件fine[Content\u Types].xml,但无法解压其他文件 这是我的解压码 public void unzip(String filepath, String filename) throws IOException { InputStream is = new FileInputStream(filepath + filename); ZipInputStream zis = new Z
public void unzip(String filepath, String filename) throws IOException {
InputStream is = new FileInputStream(filepath + filename);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
try {
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int count;
String filename_temp = ze.getName();
if (ze.isDirectory()) {
File fmd = new File(filepath + filename_temp);
fmd.mkdirs();
} else {
FileOutputStream fout = new FileOutputStream(filepath + filename_temp);
while ((count = zis.read(buffer)) != -1) {
baos.write(buffer, 0, count);
byte[] bytes = baos.toByteArray();
fout.write(bytes);
baos.reset();
}
fout.close();
}
}
} finally {
zis.close();
}
}
我不是安卓应用程序开发者。但我在Golang遇到了同样的问题。问题不在于文件,而在于文件夹。您必须设置文件夹_rels的创建权限。在我的例子中,我提取了一个.docx文件,我只需要数据文件“word/document.xml”,所以我为文件夹“word”设置了权限,并单独提取了该文件夹。如果您也在寻找.xlsx的数据文件,那么它就是“xl/worksheets/sheet1.xml”。在您的情况下,您必须对“xl”和“工作表”都给予许可。 希望这会有所帮助 注意:我的android知识非常有限,但我认为您必须在源代码本身而不是清单文件上对访问外部文件或文件夹的权限进行写入