在 Scala 中发出本机系统命令 [英] Issuing native system commands in Scala

查看:16
本文介绍了在 Scala 中发出本机系统命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 Scala 程序发出本机系统命令,并可能捕获输出.(想到ls".可能有其他方法可以在不发出命令的情况下获取目录信息,但这与我的问题无关.)它将对应于 Python 中的 os.system(...).

I want to issue a native system command from a Scala program, and perhaps trap the output. ("ls" comes to mind. There may be other ways to get directory information without issuing the command, but that's beside the point of my question.) It would correspond to os.system(...) in Python.

我看过Scala 编程".我看过 O'Reilly 的Programming Scala".我用谷歌搜索了几种术语组合.还没有运气.有人可以给我一个例子,或者指向我可以找到一个例子的资源吗?

I've looked in "Programming in Scala". I've looked in O'Reilly's "Programming Scala". I've Googled several combinations of terms. No luck yet. Can someone out there give me an example, or point me at a resource where I can find an example?

推荐答案

最好的方法是使用 scala.sys.process.

这篇关于在 Scala 中发出本机系统命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆