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/>,|*http://wso2.com
*lean . enterprise . middleware*

mobile +94 772 916 596 ,

Reply via email to