Task
Execute a system command and get its output into the program. The output may be stored in any kind of collection (array, list, etc.).




Related task
  Execute a system command


// version 1.0.6
 
import java.util.Scanner
 
fun main(args: Array<String>) {
    val command = "cmd /c chcp"
    val p = Runtime.getRuntime().exec(command)
    val sc = Scanner(p.inputStream)
    println(sc.nextLine())
    sc.close()
}