Win a copy of Rust Web Development this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Split String Based On String Length issue

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.



>
 
author & internet detective
Posts: 40913
840
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Samn,
Can you add an iff statement to address that case?
 
Marshal
Posts: 74684
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Marshal
Posts: 74684
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Closing as duplicate. Read this.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic