个人博客转至:tybai.com

无聊就想打码,打码使我快乐


Fork me on GitHub

scala调用Linux命令行

scala 里面存在 调用 Linux 命令行的函数:

import scala.sys.process._

执行的方法也不难:

import scala.sys.process._

/**
  * Created by TTyb on 2017/5/22.
  */
object test1 {
  def main(args: Array[String]): Unit = {
    val cmd = "history"
    val result = cmd.!!
    // 查看返回的结果
    println(result)
  }

}

需要注意的是,这个库只能调用 Linux 的命令行,在 Windows 下不行

posted on 2017-05-22 20:57  TTyb  阅读(1306)  评论(0编辑  收藏  举报

导航


不用多久

我就会升职加薪

当上总经理

出任CEO

迎娶白富美

走上人生巅峰

Pulpit rock