Skip to content

Toolkit Files and Processes missing io.File and nio.Path interop details #2883

Closed
@DavidGoodenough

Description

@DavidGoodenough

In the section https://docs.scala-lang.org/toolkit/os-intro.html there is information on how to use op.Path and friends on its own, but nothing about how to convert java.io.File and java.nio.Path objects to and from os.Path.

As this site is going to be the first place that new users visit before using the Toolkit, and in many cases there will be need to use the old Java classes to integrate with other libraries (such as JavaFX and its file and directory choosers) the lack of any mention of interworking is likely to put people off trying the Toolkit.

In addition the context prompts in IDEs such as VsCode do not offer the implicit conversions, so when you got to create an os.Path you are not offered the ability to pass it an io.File, just the ability to pass it a PathConvert or String.

So I would suggest a short extra page, or an extra paragraph on the last page in the os-intro section which says something like:-

os.Path objects can be created from existing java.io.File and java.nio.Path objects by passing them to the constructor/apply, and if you need to get an io.File you can use the toIo method, and for an nio.Path the toNio method.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions