3
문자열로 변환 된 XML 목록을 압축하려고 하나의 zip 파일에 저장하고 POST 본체로 되돌아갑니다. 그러나 파일을 저장할 때마다 "아카이브가 알 수없는 형식이거나 손상되었습니다."라는 오류 메시지가 나타납니다.압축 (Zip) ZipOutPutStream을 사용하여 파일 목록 Java
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;
}
아무도 도와 줄 수 있습니까?
네트워크로 전송하기 전에 zip 파일을 검사 해 보셨습니까? – nandsito
사용중인 charset은 무엇입니까? String의 길이가 바이트 배열의 길이와 항상 일치하지는 않기 때문입니다. – Boschi
@nandsito 아니오 ZipOutputStream에 대한 함수가 있습니까? –