on 06-22-2007 5:04 AM
Hi ,
I have a UDF via which I am taking the input string and for every 132 characters of input string I split in show it in a different line of an idoc.
It is working fine for 2 lines .However when I get 3 lines i.e. anything more then
395 characters I get this error
StringIndexOutOfBoundException
following is the code I am using in the udf.
public void deriveTEXT(String[] a,ResultList result,Container container){
for(int i=0;i<a.length;i++)
{
int len=a<i>.length();
int variant=132;
int count=len/variant;
int initial=0;
int fin=0;
if(count>=1)
{
fin=variant;
}
else
{
fin=a<i>.length();
}
for(int j=0;j<count;j++)
{
result.addValue(a<i>.substring(initial,fin));
initial=fin;
fin=2*fin;
}
result.addValue(a<i>.substring(initial,a<i>.length()));
if(i<a.length-1)
result.addContextChange();
}
Kindly help.
Hi ,
Just small change required .
your code
for(int j=0;j<count;j++)
{
result.addValue(a.substring(initial,fin));
initial=fin;
fin=2*fin;
}
Change it to
for(int j=0;j<count;j++)
{
result.addValue(a.substring(initial,fin));
initial=fin;
fin=fin+132;
}
Thanks ,
Suvarna
Award pts if it helps .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deepak,
Try this..
<i>Change the following int len=a.length(); to</i>
int len = a[ i ].length();
ignore the space in between [ ]
Regards,
Sumit
Message was edited by:
Sumit Khetawat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deepak,
This error coours when for example check word.length() and make sure that it is greater than the index that you are checking. The index must be between 0 and s.length()-1.
Regards,
Subhasha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Deepak,
Why u are using Queue here ,are u going to get multiple inputs . Also in ur code first line in loop u are using for(int i=0;i<a.length;i++) and in second line u are using int len= a.length(). Both are misleading , can u please clarify?
Best regards,
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sharma,
Its complalining about the substring functionality. It is failing there. So please check that.
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.