We have zipped(deflated) content in the form of byte[] which was uploaded using Java language.
Now we want to unzip it and then convert the byte[] to UTF_8 string in cpp.
Sample working unzip code in Java that we want to replicate in cpp:
public String unzipByteArray(byte[] file) {
Inflater decompresser = new Inflater();
decompresser.setInput(file);
byte[] result = new byte[1024*1024*8];
int resultLength = 0;
try {
resultLength = decompresser.inflate(result);
decompresser.end();
return new String(result, 0, resultLength, StandardCharsets.UTF_8);
} catch (DataFormatException e) {
System.out.println("+++++++ caught exception while inflation " + e.toString());
return "";
}
}
Aucun commentaire:
Enregistrer un commentaire