954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

split text in java

Hey guys, I have a problem, I have to take a text and depending if a boolean - split_words is true or false I have to parse the text on some lines splitting the words or leaving them whole.
for example, text is: This is the text I have to split.
and
split_words = true

0123456789
This is th
e text I h
ave to spl
it


split_words = false

0123456789
This is 
the text I
have to
split


the 0123456789 are just for guidelines.
I managed to do the part for split_words = true, I can seem to figure out to do it for split_words=false.

p.s.
it seems the text arrangement gets change when I post but I hope you get the ideea behind the split.

Alex86fire
Newbie Poster
4 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

Okay? For the first one a simple substr in a loop. In the second one a simple substr in a loop combined with charAt to determine the index.

Using those hints, give it a try and then post your code with a specific question.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Thank you for the idea, I finally managed to do it.
for split=true code is pretty intuitive, for false it took a little work but I managed to finish it.
I can't post the code yet because the homework is still active but if you don't mind I can pm you the code and you can give me feedback on how I can optimize it.

thanks again for the help.

Alex86fire
Newbie Poster
4 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: