please help me


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: please help me

  1. #1
    Join Date
    Oct 2006
    Posts
    28

    please help me

    iam reading following line by buffered reader ........but program throwing some indexout of bound exception .Can u any vody help me. this following line make problem
    <edm:OrderItem><edm:OrderItemReconciliation orderREF="1036578"/></edm:OrderItem>.I need to get out put as 1036578 and also in some case the line comes this way <edm:OrderItemReconciliation orderREF="1035538"> ineed to handle both ways...but one time it written on file if ithese come in same line can u explain with code

  2. #2
    Join Date
    Dec 2005
    Posts
    97
    ok here try this..
    Code:
    import java.util.StringTokenizer;
    // the rest of your code
    
    String tempString = in.readLine() // tempString now contains the OrderItem thing
    int position = tempString.indexOf("\""); // locates the first occurance of the quotation mark
    position++;
    tempString = tempString.substring(position, tempString.length());
    StringTokenizer mainToken = new StringTokenizer(tempString);
    tempString = mainToken.nextToken("\"");
    this should get the number every time.

  3. #3
    Join Date
    Oct 2006
    Posts
    28
    iam using string delimiter instead of tokenizer.can u please tell what is problen in code in above criteria....
    final String START6_TAG="orderREF=";
    final String END6_TAG=">";
    final String END7_TAG="/>";

    if(line.indexOf(START6_TAG)> -1 ) { if(line.indexOf(END7_TAG)>-1){
    //efound9=true;
    }
    if(efound9==false)
    {
    System.out.println("hello");
    // start5Pos = line.indexOf(START6_TAG)+1;
    start5Pos = line.indexOf(START6_TAG)+1;
    System.out.println("index"+START6_TAG);
    System.out.println("index"+start5Pos);
    start5Pos += START6_TAG.length();
    System.out.println("length"+start5Pos);
    // end5Pos = line.indexOf(END6_TAG)-2;
    end5Pos = line.indexOf("\">",start5Pos);
    System.out.println("index"+ end5Pos );
    efound7=true;
    //while (endPos == -1 && line != null)
    }

    }
    else
    efound7=false;
    if ((efound7 == true))
    {
    br1.write("\t");
    System.out.println("startposition"+start5Pos);
    //System.out.println("startposition"+start5Pos);
    System.out.println("end5position"+end5Pos);
    //System.out.println("startposition"+start5Pos);
    System.out.println("Exception occured"+line);
    br1.write(line.substring(start5Pos,end5Pos));
    //br1.write((START2_TAG)+line.substring(startPos,endPos)+(END2_TAG));
    br1.flush();

    } else {
    System.out.println("efound6 Not found");
    }
    if i use above code i just think chance of problem occured, because lot of("\""); comes on line i only just show problem occured.reading lines....there are lot of lines contains...("\"");
    Last edited by loveme; 10-30-2006 at 11:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center