mindweaver
asked on
Split string at a certain length and put into an array
Hey
I am working on a news ticker and I present text from a mySQL-database. As it is now I have put in "\n" in my table cells and using StringTokenizer and .split to separate the lines into an array. What I want to do now is to be able to remove the "\n"'s in my database tablecells and to read in the string as a whole. After that I want to use the .split function to cut the string at a certain letter number (length) so at every, let's say, 20th character I want it to split and put those 20 chars as a string into an array.
This is my code as it is now. (working)
String lines[] = text.split("\\u005cn"); // \u005c is the hex code for the backslash (92 decimal) Splitting up the text and entering the parts into an array
Is it possible to do what I am requesting?
I am working on a news ticker and I present text from a mySQL-database. As it is now I have put in "\n" in my table cells and using StringTokenizer and .split to separate the lines into an array. What I want to do now is to be able to remove the "\n"'s in my database tablecells and to read in the string as a whole. After that I want to use the .split function to cut the string at a certain letter number (length) so at every, let's say, 20th character I want it to split and put those 20 chars as a string into an array.
This is my code as it is now. (working)
String lines[] = text.split("\\u005cn"); // \u005c is the hex code for the backslash (92 decimal) Splitting up the text and entering the parts into an array
Is it possible to do what I am requesting?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.