Hi,
I juz started making a Jump'n'run engine.
So we need an editor.
Now we are @ the part to save the finished map.
I want to save the data as a Base64 encoded ZLib Compressed String.
Earlier i used Ruby to compress and encode the string, now i want to use java.
But the result of the Compression is kinda buggy, it always gives me:
java.util.zip.DataFormatException: incorrect header check
The Inflater part should be OK, becauze it worked earlier fine.
I think its a problem how i compressed the string.
Heres my code:
1 2 3 4 5 6 7 8 9
| byte[] bytes = (String)layerCodes[i].getBytes("UTF-8"); bytelength=bytes.length; byte[] output = new byte[bytes.length]; Deflater compresser = new Deflater(); compresser.setInput(bytes); compresser.finish(); int compressedDataLength = compresser.deflate(output); layerCodes[i] = new String(output, 0, compressedDataLength, "UTF-8"); layerCodes[i] = Base64Decoder.encodeString(layerCodes[i].trim()); |
I dont get it what i've done wrong;
1
| byte[] output = new byte[bytes.length]; |
Have i to put the exact output lenght?
Base64 En/De-Coder:
http://www.source-code.biz/base64coder/java/Edit:
A clean result should look like this:
1
| eJwz0DHQMbYwswYABtMBlQ== |
But thats the result from Java method:
._.
Something have to be wrong, the base64 encoder`? but i printed the String before encoding and after decoding, they was the same.
Edit: solved, juz kiked the compression out of my code