How we can split a given String at particular string or character as I do not wants to use Split function of android, is there any alternative available for that?
Asked
Active
Viewed 229 times
0
-
Please show some of your code so we can be of more help. – Albert Xing Jan 16 '14 at 16:32
-
as I just used somestring.Split("a:b:c",":")[0] but I wants to write some code that it will work in a smooth way so wantsto look for an alternate code as I had an error that split function not defined so I am looking for alternate – Jan 16 '14 at 16:36
2 Answers
2
I would recon as an alternative the GUAVA Lib.
http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Splitter.html

Kitesurfer
- 3,438
- 2
- 29
- 47
1
StringTokenizer is a good alternative, if you don't mind the iterative nature.
Here's a post related to that: Android Split string
For example, from that post:
String myStr = "Fruit: they taste good";
StringTokenizer tokens = new StringTokenizer(myStr, ":");
String first = tokens.nextToken();// this will contain "Fruit"
String second = tokens.nextToken();// this will contain " they taste good"
-
it is somewhere a specific answer as it was assumed the string has always that syntax (foo: bar)..etc – Jan 16 '14 at 16:27