Tuesday, June 24, 2014

Re: StringTokenizer in GWT

Keep in mind that performance in the JVM is not the same as performance in GWT once compiled to JS.

In GWT, if you don't need regexp and only have one separator char, you'd probably better use indexOf and substring I guess.
If you need regexps, or have several separators, then using com.google.gwt.regexp (in the same way as indexOf) would work and should be fast.
…or you could use Guava's Splitter.

On Tuesday, June 24, 2014 3:02:09 PM UTC+2, Boštjan Pajntar wrote:
StringTokenizer is not depracatd though. There is also a good reason for this, as it is quite faster than the split method.

Check a comparison


Dne petek, 01. avgust 2008 04:48:17 UTC+2 je oseba Kroc napisala:
I don't know for this error.

but from javadoc API you can read this:
StringTokenizer is a legacy class that is retained for compatibility
reasons although its use is discouraged in new code. It is recommended
that anyone seeking this functionality use the split  method of String
or the java.util.regex package instead.

So, try other method.
I'm sucessfully using split method.

Vincent

On 1 août, 10:12, Anti <zer...@gmail.com> wrote:
> Hello Everybody,
>
> StringTokenizer is very useful but seems I cannot use it in GWT, these
> lines of code:
>
>                         StringTokenizer stringTokenizer = new
> StringTokenizer(sender.getFileName(), "\\");
>                         while(stringTokenizer.hasMoreTokens()){
>                                 shortName = stringTokenizer.nextToken();
>                         }
>
> throw...:
>
> Line 72:  No source code is available for type
> java.util.StringTokenizer; did you forget to inherit a required
> module?
>
> What can I do?
>
> Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment