Results 1 to 8 of 8
- 09-24-2009, 08:42 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 24
- Rep Power
- 0
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
- 09-24-2009, 10:43 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 09-24-2009, 10:52 AM #3
Member
- Join Date
- Sep 2009
- Posts
- 24
- Rep Power
- 0
first u read my thread completely.
then only answer the question.
- 09-24-2009, 11:13 AM #4
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
RamyaRamya:cool:
- 09-24-2009, 12:14 PM #5
Member
- Join Date
- Sep 2009
- Posts
- 24
- Rep Power
- 0
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.
- 09-25-2009, 06:22 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-25-2009, 08:22 AM #7
Member
- Join Date
- Sep 2009
- Posts
- 24
- Rep Power
- 0
what is this..
- 09-25-2009, 07:25 PM #8
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Similar Threads
-
[SOLVED] Array index out of bounds exception
By sruthi_2009 in forum New To JavaReplies: 5Last Post: 11-24-2010, 11:46 AM -
Exception in thread "main" javax.naming.NameNotFoundException: jmx not bound
By Vartika in forum Advanced JavaReplies: 2Last Post: 08-07-2009, 10:21 PM -
Array Index problems
By ragnor2004 in forum New To JavaReplies: 4Last Post: 03-26-2009, 07:53 PM -
ArrayIndexout of Bound exception
By Preethi in forum New To JavaReplies: 2Last Post: 02-14-2008, 09:40 PM -
problems with array index
By mary in forum New To JavaReplies: 2Last Post: 08-01-2007, 04:30 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks