I had problem in converting blob object (which was stored as zip) to string. since i used different encoding format while reading from the database vs encoding used by database to convert the data to blob object.
below code creates problem if i use different encoding
i fix the issue by replacing the above code with the below one
so please advice me whether it is correct approach to fix the problem in case of reading the file in different encoding . i feel there is no much difference between code, but second code fix my problem (educate me how does the second code fix the issue).
dhoni Gibson wrote:I had problem in converting blob object (which was stored as zip) to string.
If the BLOB data was originally a ZIP archive, then it doesn't make sense to convert it to a string. It isn't text data so it shouldn't be treated as a string.
However it's impossible to answer your question specifically about character encoding in your code, because the fragments you posted don't show any evidence of character encodings being used. Could you perhaps show us where you think you are using a character encoding?
Character encodings are only used when bytes are converted to chars, or vice versa. Your code doesn't have any such examples. And BLOBs are binary objects, so producing a BLOB from bytes doesn't involve any character encoding.
I'm not sure if this affecting you, but Java had a problem with foreign characters in ZipEntry. Apparently, that's fixed in Java 7, but if you're using an earlier JDK, that could be causing you problems. http://bugs.sun.com/view_bug.do?bug_id=4244499
Thanks for your post. i read through the link and learned issue was between two different platforms while encoding characaters.my issue is bit different, I am running my application in unix environment where i had issue while reading through zip file. i happen where my zip data is persisited in db and while reading through the java code i couldnt recreate the data inside the data.
i have fixed the issue which i have mentioned in the previous post.
i want to know whether i need to use same encoding format which my database is using.
i am using oracle database which uses US7ASCII as encoding . where as my jvm uses US-ASCII.
No, I don't think it matters. Blobs are binary data and therefore not encoded. You might have to match encodings between whatever produced the zip file entry names and whatever is consuming them, but I can't see how Oracle's preferred encoding would make any difference.