Solved

Split string at a certain length and put into an array

Posted on 2004-10-17
1
217 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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…

803 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