wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Question on string array values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on string array values" Watch "Question on string array values" New topic
Author

Question on string array values

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

I have taken a string value in some test code and found all the "\n" values in the string via the split method and created a string array (notes) for each split value. However now I am needing to breakup each string[] (notes) value to a 45 char max length and create a new string for each 45 char length or less for each string[] value until I get to end of that string[] value.

Any suggestions or direction would be greatly appreciated.

Here is the code I am working with:

Srikanth Ramu
Ranch Hand

Joined: Feb 20, 2007
Posts: 76
Take each element of the array and use length() and substring(int beginIndex, int endIndex) methods.

For more details:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Ok, I took a crack at the problem I explained above, but I am needing to break apart "noteLine" into 45 char chunk lines for each element in my string array and therefore the reason for this post.

Any help or direction would be greatly appreciated. Regards.

Here is the code I came up with but would appreciate any help:

Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3432
    
  12
The following method should split each line into an array of String each 45 characters long (apart possibly from the last one).
I haven't tested it, so you may need to play around with the array indexes and substring parameters a little.


Joanne
Guido Sautter
Ranch Hand

Joined: Dec 22, 2004
Posts: 142
If you don't want to break up words, you might want to try this one:

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Hey guys,

Thanks so much for your time and help. I will give this a try.

Again, thanks so much.

Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on string array values
 
Similar Threads
Sun Cirtification
Counting in Array List/ Standard deviation
String split
Simple J2SE 5.0 Tiger Notes
2D array