Function to unpack xml does not work in Linux

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 it comes without a character and without the closing of the tag, for example:

Instead of coming like this:

<NFse>
   Conteúdo...
</NFse>

It's coming like this:

<NFse>
   Conteúdo...
</NFs

Zip 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;
}

Unpacking function:

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 missing code?

    
asked by anonymous 06.11.2015 / 13:38

0 answers