Scala “split string” examples (field separator, delimiter)
Scala String
FAQ: How do I split a String
in Scala based on a field separator, such as a String
I get from a comma-separated value (CSV) file or pipe-delimited file.
Solution
Use one of the split
methods that are available on Scala/Java String
objects. For instance, this example in the Scala REPL shows how to split a string based on a blank space: