dprogrammer Posted April 22, 2009 Share Posted April 22, 2009 I am using split function as follows. It only works if the number of elements in a string is equal to [ ] index. But if I increase the index to [4] but keep the string same ,it throws an error "java.lang.ArrayIndexOutOfBoundsException: 4 ". Below is just a sample string and in actuality a field will be replaced with the string "abc...". Since the field may contain from 1 to several elements, I am not sure how to dynamically use split function there. Thanks in advance for your valuable input.("abc;def;ghi;jkl").split(";")[0]+"\n\r"+("abc;def;ghi;jkl").split(";")[1]+"\n\r"+("abc;def;ghi;jkl").split(";")[2]+"\n\r"+("abc;def;ghi;jkl").split(";")[3] -- untill here works fine with the given string+"\n\r"+("abc;def;ghi;jkl").split(";")[4] -- with addition of 4 (5th line) in index it throws error Link to comment Share on other sites More sharing options...
vishal29bhp Posted April 23, 2009 Share Posted April 23, 2009 See the split method returns the array of String[] so if you call "abc;def;ghi;jkl".split(";"); then it returns {"abc","def","ghi","jkl"} as Array of String[]. Now if you calling split() method so it must be in the loop. Vishal Link to comment Share on other sites More sharing options...
dprogrammer Posted April 23, 2009 Author Share Posted April 23, 2009 Thanks Vishal. But I dont' think we can write a loop expression in iReport? Can we? There must be an easier way to split the string. This is very common feature in almost all programming languages and reporting tools. Link to comment Share on other sites More sharing options...
vishal29bhp Posted April 24, 2009 Share Posted April 24, 2009 If you want loop in iReport then you have to make a Scriptlet for it which is java code. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now