I have a method that splits a string and continues with its logic after.
Now this method works in say a console or fx but using Codename One I get
error: cannot find symbol
for (String word : comment.split("\\s+"))
symbol: method split(String)
location: variable comment of type String
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Now I know that Codename One is not the FULL JSK but more a restricted subset but I haven't found an alternative to splitting a string.
Should I create my own method or is there a way around to use another function?
For anyone looking to make their life easier here is a convenience method
public String[] split(String str)
{
ArrayList<String> splitArray = new ArrayList<>();
StringTokenizer arr = new StringTokenizer(str, ",");//split by commas
while(arr.hasMoreTokens())
splitArray.add(arr.nextToken());
return splitArray.toArray(new String[splitArray.size()]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With