Reputation: 1462
I am working over an hour to find a way to explode a string into a string array.
This method have failed for me:
lineFields = str.split("|");
System.out.print(lineFields.length);
because it gives back an array of equal length to the string it self.
Then I read here that string tokenizer can explode a string, but unfortunately I cannot find a way to access the element randomly like lineFields[1]
.
I come from php and doing the simpliest things here looks so unusual, and of course I have searched the relative post on this forum, but still nothing close to my needs.
Upvotes: 2
Views: 964
Reputation: 285405
split(...)
should be used.|
String: "\\|"
Upvotes: 3