Solved

Split string at a certain length and put into an array

Posted on 2004-10-17
1
215 Views
Last Modified: 2010-03-31
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?
0
Comment
Question by:mindweaver
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12335257
to split every number of characters you'd use substring() instead of split()
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Understanding websocket example in spring 1 54
splitOdd10 challenge 5 74
VB Script to add site to Java Exception List 4 48
xampp tool 12 24
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now