How can one create a java.nio.Path that represents no path no matter the environment?
I cannot call Path.of(<String>)
and guarantee the resulting path to point to an invalid file or directory.
What I'm looking for is if there is a safer way to represent an empty / invalid path than using a null
value.
Depending on your use case, there are a couple options:
Optional<Path>
and return Optional.empty()
to denote no path.