Jasintha, The sample code doesn't really show what you are trying to achieve. Obviously you wouldn't use Axiom to read the content of a file into a String, so what is the actual use case?
Andreas On Tue, Oct 25, 2011 at 06:48, Jasintha Dasanayaka <[email protected]> wrote: > Hi Andreas > > According to you Answer in issue[1] I have modified the method as follows > is this the correct way to do this If not could you please suggest a correct > way > > > > private static String readFile(String file) throws IOException, > XMLStreamException { > > FileInputStream fin = new FileInputStream(file); > OMFactory factory = OMAbstractFactory.getOMFactory(); > String charSetEnc = BuilderUtil.getCharSetEncoding("text/plain"); > QName wrapperQName = BaseConstants.DEFAULT_TEXT_WRAPPER; > Reader reader; > try { > reader = new InputStreamReader(fin, charSetEnc); > } catch (UnsupportedEncodingException ex) { > throw new AxisFault("Unsupported encoding: " + charSetEnc, ex); > } > OMElement om = new OMSourcedElementImpl(wrapperQName, factory, > new WrappedTextNodeOMDataSourceFromReader(wrapperQName, > reader)); > om.serialize(System.out); > > /* before modify > OMNode textNode = om.getFirstOMChild(); > OMText text = (OMText) textNode; > return text.getText(); > */ > > StringBuffer buffer = new StringBuffer(); > Iterator<OMNode> iterator = om.getChildren(); > while(iterator.hasNext()){ > OMText text = (OMText) iterator.next(); > buffer.append(text.getText()); > } > > return buffer.toString(); > > } > > > Thanks & Regards > /Jasintha > > [1]-https://issues.apache.org/jira/browse/AXIOM-395 > > -- > Thanks & Regards > > Jasintha Dasanayake > Software Engineer. > > WSO2 Inc,|http://wso2.com > lean . enterprise . middleware > > mobile +94 772 916 596 , > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
