How can I get the current directory (working directory) of the executing program in Scala?
In SparkR, the default working directory is "/usr/hdp/2.4. 0.0-169/spark".
Getwd functionis used to get the current working directory in Golang, the function returns the rooted path name and if the current directory can be reached via multiple paths, the function can return any one of them.
Use java.nio
:
import java.nio.file.Paths
println(Paths.get(".").toAbsolutePath)
Remark on scala.reflect.io.File
: I don't see any reason to look into scala.reflect
packages for such mundane tasks. Getting the current working directory has usually nothing to do with Scala's reflection capabilities. Here are more reasons not to use scala.reflect.io.File
: link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With