Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
16
Task/Fork/Scala/fork-1.scala
Normal file
16
Task/Fork/Scala/fork-1.scala
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import java.io.IOException
|
||||
|
||||
object Fork extends App {
|
||||
val builder: ProcessBuilder = new ProcessBuilder()
|
||||
val currentUser: String = builder.environment.get("USER")
|
||||
val command: java.util.List[String] = java.util.Arrays.asList("ps", "-f", "-U", currentUser)
|
||||
builder.command(command)
|
||||
try {
|
||||
val lines = scala.io.Source.fromInputStream(builder.start.getInputStream).getLines()
|
||||
println(s"Output of running $command is:")
|
||||
while (lines.hasNext) println(lines.next())
|
||||
}
|
||||
catch {
|
||||
case iox: IOException => iox.printStackTrace()
|
||||
}
|
||||
}
|
||||
14
Task/Fork/Scala/fork-2.scala
Normal file
14
Task/Fork/Scala/fork-2.scala
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import java.io.IOException
|
||||
|
||||
object Fork extends App {
|
||||
val command: java.util.List[String] = java.util.Arrays.asList("cmd.exe", "/C", "ECHO.| TIME")
|
||||
val builder: ProcessBuilder = new ProcessBuilder(command)
|
||||
try {
|
||||
val lines = scala.io.Source.fromInputStream(builder.start.getInputStream).getLines()
|
||||
println(s"Output of running $command is:")
|
||||
while (lines.hasNext) println(lines.next())
|
||||
}
|
||||
catch {
|
||||
case iox: IOException => iox.printStackTrace()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue