5

私は文字列で変換された Xml のリストを圧縮しようとしています。それらを 1 つの zip ファイルに保存し、安静時に POST の本体として返します。しかし、ファイルを保存するたびに、「アーカイブは不明な形式であるか、破損しています」というエラーが表示されます。

protected ByteArrayOutputStream zip(Map<String, String> mapConvertedXml) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(baos);
    try {
        for(Map.Entry<String, String> current : mapConvertedXml.entrySet()){

            ZipEntry entry = new ZipEntry(current.getKey() + ".xml");
            entry.setSize(current.getValue().length());
            zos.putNextEntry(entry);
            zos.write(current.getValue().getBytes());
            zos.flush();
        }

        zos.close();

    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    return baos;
}

誰でもそれで私を助けることができますか?

4

1 に答える 1