我正在尝试在Scala的HDFS目录中获取文件的大小。我可以在REPL中执行以下操作:
Seq("/usr/bin/hdfs", "dfs", "-du", "-s", "/tmp/test").!
但我无法将结果存储为值。如何获取Scala目录中文件的大小?
!
您使用的方法来自ProcessBuilder
。
(Seq[String]
正在隐式转换为ProcessBuilder
,从而授予您访问权限!
)。
/** Starts the process represented by this builder,
* blocks until it exits, and returns the exit code.
*/
abstract def !: Int
如果需要输出,请使用其他方法,例如 !!
/** Starts the process represented by this builder,
* blocks until it exits, and returns the output as a String.
*/
abstract def !!: String
我建议检查出ProcessBuilder上定义的其他方法。我确信其中至少有一个能满足您的需求。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句