What is the fastest way (in terms of performance) to read from standard input in Scala? Most interesting case for me is a lots of Integers as input.
Asked
Active
Viewed 140 times
2
-
In this aspect scala is no different from java -- for low level aspects such as working with system.in scala rely on java primitives. – om-nom-nom Dec 12 '13 at 14:26
-
Here's a very basic string tokenizer that is very fast if you only have a single delimiter: https://gist.github.com/jskorpan/1056060 StringTokenizer from Java may be fast enough for your needs. It's deprecated, but it still outperforms the suggested replacements of string.split and the regular expressions library. – bdean20 Dec 12 '13 at 14:29
-
This may do better: http://stackoverflow.com/a/2698772/779314 – bdean20 Dec 12 '13 at 14:30
-
1@om-nom-nom, does the BufferedInputStream from the second example not handle that case? – bdean20 Dec 12 '13 at 15:32