-2

Assuming I have a String like this one in Android:

" This is an example String "

and i want to make it become:

"This is an example String"

I tried to use the split() but is not found in Android, is there any other method i'm not getting?

Thx

Anon
  • 502
  • 5
  • 19

1 Answers1

2

Store it in a string like this

String str = " This is an example String ";

then use the trim() method :

str.trim();

that's it! The method automatically removes spaces in front and back