In my program, I have a web application that creates a PNG image. This PNG image is written to a file and returned in a request. When I write the request to a file, it is different than the one that was originally written to the harddrive when they should be exactly the same. The PNG from the response is just a blank image. (it is corrupt i guess).
I used a binary diff program to diff the two PNG files and found that some of the characters in the response PNG were just replaced with hexadecimal value 3F instead of their real values.
Here is an image of the diff:
Diff Image
It seems as though the response is making some of the HEX values into 3F, why is this? And is there a way to make it stop doing this.
To be more specific about how that response was created, a FileRepresentation (from RESTlet) was used to get the PNG file and put it in a response. I used the RESTlet file type MEDIATYPE_PNG.
I have found the problem. I was accessing the response in the wrong way. by using response.getEntity.getText() it does not give an accurate string representation as some of the values from the file are not part of the ascii range. It replaced “?” with those values that are not in the ascii range.
So instead I just got a byte stream by using response.getEntity().getStream() from it and everything works fine.
Thanks all!