[SOLVED, it's Using.Manager] Scala's equivalent to Java's try-with-resource with multiple resources

In Java’s try-with-resource construct multiple managed resources can be used:

try(final InputStream is = new FileInputStream(file); 
    final OutputStream os = new FileOutputStream(file)) { ... }

To my knowledge, Scala’s Using is the closest equivalent to said Java’s try-with-resource construct. If I am not completely wrong and misread the respective Scaladoc, Using only manages one single resource.

What is the best pattern to handle multiple resources in Scala?

Disclaimer: I half understand that cats-effects has something for this use case, but before I start using libraries I’d like to understand how things are done in vanilla Scala.

Using.Manager, described in the Using API docs, as well.

2 Likes

I really should start reading Scaladoc on the web and not just from source files. Thank you so much for your help.