Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caps Conversion

Status
Not open for further replies.

wwworg

Programmer
Feb 10, 2006
35
CA
hey guys

Is there a function in Java that can convert a string in "ALL CAPS" format to a string in proper format . for example I have a string as "PHYSCHO PATH" and I want to convert it to "Physcho path"

Thanks

 
I know there is a .toUpperCase() and .toLowerCase(), but I want the first character of every work as Uppercase and rest lower.

any thoughts
 
More information might be needed, but would something like this work for you?:

Code:
myString = myString.substring(0, 1) + myString.toLowerCase().substring(1);

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Slight alteration to the above :

mystring = mystring.substring(0, 1).toUpperCase() + mystring.substring(1).toLowerCase();

This will always create a String where the first char is upper case, and the rest lower case, and also only converts the cases on the relevant substring.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
So the actual answer to the OP is: "No, there's not such a method in Java"

Cheers,
Dian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top