File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initcap of a string

 
Gitanjali Magani
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i get the initcap of a string?

ex: convert "search again" to "Search Again"


thanks,
gita
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no trivial, built-in-to-the-API way to do it.

With a bit of care, you could do it all at once with a regular expression, or you could do it by looping over the characters in a String, appending them to a StringBuffer, capitalizing each letter than follows whitespace.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic