java.lang.StringIndexOutOfBoundsException: String index out of range:34

Discussion in 'Java' started by Sanjeev, Jul 1, 2008.

  1. Sanjeev

    Sanjeev Guest

    Dear Gurus

    I m reading XML file in the form of string.
    Below is the code.

    => XML string that pass to parseDocument(String receivedMessage) in
    Parser class as follows

    <?xml version="1.0" encoding="UTF-8"?>
    <IFX xmlns:pain001="urn:swift:xsd:$pain.001.001.01"
    xmlns:pain002="urn:swift:xsd:$pain.002.001.01"
    xmlns:pain004="urn:swift:xsd:$pain.004.001.01"
    xmlns:remit="http://www.ifxforum.org/RemitDetailInfo/
    2004/07"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="C:\IFX170_XSD.xsd" >
    <SignonRq>
    <ClientDt>2006-02-16</ClientDt>
    <CustLangPref>EN</CustLangPref>
    <ClientApp>
    <Org>abc</Org>
    <Name>a</Name>
    <Version>1</Version>
    </ClientApp>
    </SignonRq>
    <BankSvcRq>
    <RqUID>51dc8bf5-70c3-4e36-8d03-d0fb5fc58fbd</RqUID>
    <XferAddRq>
    <RqUID>51dc8bf5-70c3-4e36-8d03-d0fb5fc58fbd</RqUID>
    <XferInfo>
    <DepAcctIdFrom>
    <AcctId>112</AcctId>
    <AcctType/>
    <AcctCur>INR</AcctCur>
    <BankInfo/>
    </DepAcctIdFrom>
    <DepAcctIdTo>
    <AcctId>54</AcctId>
    <AcctType/>
    <AcctCur>4</AcctCur>
    <BankInfo/>
    </DepAcctIdTo>
    <CurAmt>
    <Amt>2450</Amt>
    </CurAmt>
    </XferInfo>
    </XferAddRq>
    </BankSvcRq>
    </IFX>

    => Parser which parse the above string as below
    .. . . . . . .
    .. . . . . . .
    private void parseDocument(String receivedMessage) {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    try {
    //get a new instance of parser
    SAXParser sp = spf.newSAXParser();

    //parse the file and also register this class for call backs
    sp.parse(new InputSource(new
    ByteArrayInputStream(receivedMessage.getBytes())), this);
    }catch(SAXException se) {
    }catch(ParserConfigurationException pce) {
    }catch (IOException ie) {
    }
    .. . . . . . .
    .. . . . . . .

    In this code I m getting error on line started with "sp.parse(new
    InputSource(new ........."
    Stack trace of error as below
    org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at

    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:
    236)
    at
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:
    215)
    at
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
    386)
    at
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
    316)
    at
    com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:
    1438)
    java.lang.StringIndexOutOfBoundsException: String index out of range:
    34

    Could Any one help why I m getting this error..

    Thanking in Advance
    Regards
    Sanjeev
    Sanjeev, Jul 1, 2008
    #1
    1. Advertising

  2. Re: java.lang.StringIndexOutOfBoundsException: String index out of

    On Jul 2, 1:04 am, Sanjeev <> wrote:
    ...
    > Could Any one help why I m getting this error..


    Someone already tried to help you.
    <http://groups.google.com.au/group/comp.lang.java.programmer/
    browse_frm/thread/672c0ffa687010/b59fc1e8d9b0aa84>

    Seems you ignored them and abandoned the thread.
    Why should we bother trying to help you again?

    --
    Andrew Thompson
    http://pscode.org/
    Andrew Thompson, Jul 1, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yyt

    Index was out of range?

    yyt, Dec 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    468
    Hans Kesting
    Dec 19, 2003
  2. Clark Choi
    Replies:
    1
    Views:
    4,505
    Alvin Bruney
    Jan 10, 2004
  3. dutone
    Replies:
    20
    Views:
    2,084
    John C. Bollinger
    Aug 26, 2004
  4. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    270
    Tomasz Chmielewski
    Mar 4, 2008
  5. Replies:
    13
    Views:
    1,396
    Stuart
    Sep 23, 2012
Loading...

Share This Page