aspose file tools
The moose likes Java in General and the fly likes Split String Based On String Length issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Split String Based On String Length issue

San Smith
Greenhorn

Joined: Feb 10, 2008
Posts: 14
Hello

I am trying to split a string based on length(example length 5) of the string. But I am having a issues with this substring(start, end) method. I get all substring which are of length 5. But if the last substring is less than 5 then I am not getting that last substring. But I need the last substring even if it is less than 5. I am wondering if some one can help me. Let me know if anything is not clear.

Thank you for your help.



>
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26489
    
  78

Samn,
Can you add an iff statement to address that case?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Looks like an "out-by-one" error. If you have a 26 letter String you appear only to take 5 letters off 5 times. You need some way of getting the 6th part.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Closing as duplicate. Read this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Split String Based On String Length issue
 
Similar Threads
taking a particular data from a number of lines
String method query
pass values to static method
substring problem
Split String Based On String Length