Well first thing you need to do is convert the Binary Data into a
String. Do you have the code that put the XML into the BLOB? Is it on the same platform?
When you call the getBytes() method of a string, you use the default character encoding for the platform the JVM is running on. You do have the option of passing a Character encoding to the getByte() method to specify how the String is converted into Bytes. Check out the JavaDoc for getBytes() method on java.lang.String for how to do this.
Once you figure out what encoding, you then need to gather your bytes and create a String. You can do this in a loop that reads the ByteInputStream into an array. Then you can construct a string that contains your XML with the String(byte[] bytes, String charsetName) constructor.
After you have your XML in a string it is easy to open a FileWriter and write the String to the Writer.
Originally posted by Reddy Anoop:
Hello,
I need help/suggestion on how to resolve the following issue.
I need to read an xml file stored in as BLOB in an oracle table. I am able to read the file. I am stuck after this because, I am calling another java program to parse by passing in an XML file. Since I am not sure how to convert the BLOB to an xml file, I am getting no where. Any suggestions/help is greatly appreciated.
Here is what I need to do.
1. Read BLOB data type from xml
2. Convert the BLOB into an xml file and call the parser program with this
xml file as the parameter.
Regards
Anoop