簡體   English   中英

/_rels/.rels:打開失敗:ENOENT(無此文件或目錄)

[英]/_rels/.rels: open failed: ENOENT (No such file or directory)

嘗試解壓縮.xlsx文件時,標題出現錯誤。 我的清單中有寫權限。 它解壓縮了第一個文件[Content_Types] .xml,但無法解壓縮其他文件。

這是我的郵政編碼。

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();
}
}

我不是android應用程序開發人員。 但是我在Golang中遇到了同樣的問題。 問題不在於文件,而在於文件夾。 您必須為文件夾_rels設置創建權限。 在我的情況下,我正在提取一個.docx文件,而我只需要數據文件“ word / document.xml”,因此我設置了“ word”文件夾的權限並僅提取了該文件夾。 如果您也在尋找.xlsx的數據文件,那么它就是“ xl / worksheets / sheet1.xml”。 在您的情況下,您必須同時授予“ xl”和“工作表”的權限。 希望這會有所幫助。

注意:我的android知識非常有限,但是我認為您必須在源代碼本身而不是清單文件上具有訪問外部文件或文件夾的權限。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM