I have a compressed base64 string of a Microsoft Word file. How to covert this compressed base64 string into its original file in java.
I have tried this code, but could not succeed. Here is the code I am trying
public static void main(String[] args) throws IOException, DataFormatException {
File file = new File(outputFileName);
byte[] zipData = Base64.decodeBase64(compressed_base64_string);
GZIPInputStream zi = new GZIPInputStream(new ByteArrayInputStream(zipData));
String result = IOUtils.toString(zi);
zi.close();
InputStream filedata = new ByteArrayInputStream(result.getBytes("UTF-8"));
byte[] buff = new byte[1024];
FileOutputStream fos = new FileOutputStream(file);
while (filedata.read(buff) > 0) {
fos.write(buff);
}
fos.close();
}
This code is generating a zip file in which there are some xml files. But compressed_base64_string is generated from a microsoft word document. I am not able to get original document from this code. Please tell me what should I do next to get the original document