Results 1 to 8 of 8
  1. #1
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Smile Array Index Out of bound exception

    Hi
    in my application i;m trying to send file from my pc to detected bluetooth devices. after detecting the devices , i'm storing each device's info into vector and depending upon size of vector i'm writing the following code

    for(int i = 0; i <vecDevices.size();i++)
    {
    //vecServices=servRecord[i].getConnectionURL(0,false);
    DataElement serviceNameElement = servRecord[i].getAttributeValue(0x0100); //line 258
    String _serviceName = (String)serviceNameElement.getValue();
    String serviceName = _serviceName.trim();
    System.out.println(_serviceName);
    if(serviceName.equals("OBEX Object Push"))
    {
    System.out.println("[client:] A matching service has been found\n");
    try
    {
    connectionURL = servRecord[i].getConnectionURL(0,false);
    System.out.println(connectionURL+"\n");
    }
    catch (Exception e)
    {
    System.out.println("[client:] oops");
    }
    }
    }//for loop end


    but it is throwing arrayindexoutofbound exception at line 258.
    could anybody help me? what is the reason for this ..
    i've checked out the application using two bluetooth enabled phones ..
    it is printing size of vector as 2.. but throwing the same exception

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I hope you know the meaning of "ArrayOutOfBoundException". You are trying to access an array index which is out of range you define. Check that the array size and index you are accessing compatible.

  3. #3
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    first u read my thread completely.
    then only answer the question.

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    828
    Rep Power
    6

    Default

    Hi,
    Without posting the complete information,u shouldn't blame others .

    1. First of all,try to print servRecord length.

    2.Find out any object is there in the servRecord[i] before trying to getAttribute value.

    -Regards
    Ramya
    Ramya:cool:

  5. #5
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    thank u for help,
    it was my mistake..

    actually i'm new to bluetooth world .
    i was not knowing what servRecord[] actually contains..

    now my code is working properly.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by abhijit View Post
    first u read my thread completely.
    then only answer the question.
    Sorry expert,

    but it is throwing arrayindexoutofbound exception at line 258.
    could anybody help me? what is the reason for this ..

  7. #7
    abhijit is offline Member
    Join Date
    Sep 2009
    Posts
    24
    Rep Power
    0

    Default

    what is this..

  8. #8
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    6

    Default

    I would say it is a reaction on your stupid lets-blame-the-first-person-that-tries-to-help-me-attitude
    I die a little on the inside...
    Every time I get shot.

Similar Threads

  1. [SOLVED] Array index out of bounds exception
    By sruthi_2009 in forum New To Java
    Replies: 6
    Last Post: 03-23-2014, 10:16 AM
  2. Replies: 2
    Last Post: 08-07-2009, 10:21 PM
  3. Array Index problems
    By ragnor2004 in forum New To Java
    Replies: 4
    Last Post: 03-26-2009, 07:53 PM
  4. ArrayIndexout of Bound exception
    By Preethi in forum New To Java
    Replies: 2
    Last Post: 02-14-2008, 09:40 PM
  5. problems with array index
    By mary in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 04:30 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
  •