0
In my application I use a function to zip the xml files to save them in the database. When I unzip it to make the file available for download the xml does not come complete, at the end of the file comes without a character and without closing the tag, for example:
Instead of coming like this:
<NFse>
Conteúdo...
</NFse>
It’s coming like this:
<NFse>
Conteúdo...
</NFs
Detail that this happens only when the application is deployed on the linux server, on my machine (windows) the download occurs perfectly.
Zipping function:
public static byte[] compressBytes(String data) throws UnsupportedEncodingException, IOException {
if (data == null) {
return null;
}
byte[] input = data.getBytes("UTF-8"); //the format... data is the total string
Deflater df = new Deflater();
df.setInput(input);
ByteArrayOutputStream baos = new ByteArrayOutputStream(input.length);
df.finish();
byte[] buff = new byte[1024]; //segment segment pop....segment set 1024
while (!df.finished()) {
int count = df.deflate(buff); //returns the generated code... index
baos.write(buff, 0, count); //write 4m 0 to count
}
baos.close();
byte[] output = baos.toByteArray();
return output;
}
Function to unpack:
public static String extractBytes(byte[] input) throws UnsupportedEncodingException, IOException, DataFormatException {
if (input == null) {
return null;
}
Inflater ifl = new Inflater(); //mainly generate the extraction
ifl.setInput(input);
ByteArrayOutputStream baos = new ByteArrayOutputStream(input.length);
byte[] buff = new byte[1024];
while (!ifl.finished()) {
int count = ifl.inflate(buff);
baos.write(buff, 0, count);
}
baos.close();
byte[] output = baos.toByteArray();
return new String(output);
}
What should be the problem, my linux server or some code that is missing?
Managed to solve your problem?
– durtto
Worse than not yet boy! The mistake keeps happening.
– Gilvan André