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 下不行

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-10
  • 2021-10-01
猜你喜欢
  • 2021-06-07
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案