12.0. Introduction

When it comes to working with files, the scala.io.Source class and its companion object offer some nice simplifications compared to Java. Not only does Source make it easy to open and read text files, but it also makes it easy to accomplish other tasks, such as downloading content from URLs, or substituting a String for a File, which is useful for testing. The Scala Console class also simplifies console interaction, letting you print to the console (command line) and read from it very easily. In other cases, such as when reading a YAML file or working with directories, you simply fall back to use existing Java libraries.

Scala also makes it much easier to execute system commands. When it comes to interacting with system processes, the Scala API designers created a clean and familiar API to let you run external commands. This is useful for applications, and it’s terrific for scripts.

Get Scala Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.