【问题标题】:How to delete files on Windows with Rapture IO如何使用 Rapture IO 在 Windows 上删除文件
【发布时间】:2017-08-27 13:57:12
【问题描述】:

我正在编写 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

如何避免错误?

【问题讨论】:

    标签: windows scala rapture.io


    【解决方案1】:

    您缺少导入:

    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 方案时尝试构建的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-08
      • 1970-01-01
      • 1970-01-01
      • 2021-12-20
      • 2013-10-17
      • 2020-01-09
      • 2022-06-25
      • 2012-03-04
      相关资源
      最近更新 更多