我正在编写Scala代码。使用Rapture在Windows上运行文件时,编写URI的正确路径架构是什么?我添加了以下依赖项:
libraryDependencies += "com.propensive" %% "rapture" % "2.0.0-M3" exclude("com.propensive","rapture-json-lift_2.11")
以下是我的代码的一部分:
import rapture.uri._
import rapture.io._
val file = uri"file:///C:/opt/eric/spark-demo"
file.delete()
但我收到了消息:
Error:(17, 16) value file is not a member of object rapture.uri.UriContext
val file = uri"file:///C:/opt/eric/spark-demo"
或者我试过这个:
val file = uri"file://opt/eric/spark-demo"
同样的错误:
Error:(17, 16) value file is not a member of object rapture.uri.UriContext
val file = uri"file://opt/eric/spark-demo"
我的本地路径是:
C:\opt\eric\spark-demo
如何避免错误?
答案 0 :(得分:0)
您错过了导入:
import rapture.io._
import rapture.uri._
import rapture.fs._
val file = uri"file:///C:/opt/eric/spark-demo"
file.delete()
rapture.fs
是定义EnrichedFileUriContext
隐式类的包,这是uri宏在提供file
URI方案时要构建的。