File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Initcap of a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Initcap of a string" Watch "Initcap of a string" New topic
Author

Initcap of a string

Gitanjali Magani
Greenhorn

Joined: Oct 21, 2005
Posts: 3
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

Joined: Jul 08, 2003
Posts: 24189
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: Initcap of a string