poweranger77
asked on
ByteArrayInputStream problems.
I have some problems.. and i have tested it's really because of that. I just dont understand why. Anyone can help to tell me why.
i have this:
..
..
String xml_data = rs.getBlob("XML_PARSED_DAT A");
byte[] b1 = xml_data.getBytes(1, (int) xml_data.length());
ByteArrayInputStream xml_in_byte1 = new java.io.ByteArrayInputStre am(b1);
ByteArrayInputStream xml_in_byte2 = new java.io.ByteArrayInputStre am(b1);
ByteArrayInputStream xml_in_byte3 = new java.io.ByteArrayInputStre am(b1);
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml_in_byte1 );
Element root = doc.getRootElement();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml_in_byte2 );
Element root = doc.getRootElement();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml_in_byte3 );
Element root = doc.getRootElement();
..
..
this variable, if i keep on reusing it, it'll have error with me. And if i didnt repeat to declare multiple time, i will safe. I am wondering any limitation with this [ByteArrayInputStream ] datatype?
i have this:
..
..
String xml_data = rs.getBlob("XML_PARSED_DAT
byte[] b1 = xml_data.getBytes(1, (int) xml_data.length());
ByteArrayInputStream xml_in_byte1 = new java.io.ByteArrayInputStre
ByteArrayInputStream xml_in_byte2 = new java.io.ByteArrayInputStre
ByteArrayInputStream xml_in_byte3 = new java.io.ByteArrayInputStre
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml_in_byte1
Element root = doc.getRootElement();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml_in_byte2
Element root = doc.getRootElement();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml_in_byte3
Element root = doc.getRootElement();
..
..
this variable, if i keep on reusing it, it'll have error with me. And if i didnt repeat to declare multiple time, i will safe. I am wondering any limitation with this [ByteArrayInputStream ] datatype?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
All you need is
Document doc = builder.build(new StringReader(xml_data));
Document doc = builder.build(new StringReader(xml_data));
Yeah....
I don't understand why you are creating three instances of ByteArrayInputStream and only one of the byte[] array.
If you want to do it that way u need to create three instanes of the byte[] array.
Cheers,
Leo
I don't understand why you are creating three instances of ByteArrayInputStream and only one of the byte[] array.
If you want to do it that way u need to create three instanes of the byte[] array.
Cheers,
Leo
>> SAXBuilder builder = new SAXBuilder();
You're also declaring that three times. You can remove the other two.
You're also declaring that three times. You can remove the other two.
You'd be better using Reader/Writer with text-based input
and wht is the error u r getting?