File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
scala-libraries-3/src/main/scala/com/baeldung/scala/os Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -280,7 +280,8 @@ lazy val scala_libraries_3 = (project in file("scala-libraries-3"))
280
280
libraryDependencies ++= Seq (
281
281
" org.apache.logging.log4j" %% " log4j-api-scala" % " 12.0" ,
282
282
" org.apache.logging.log4j" % " log4j-core" % " 2.13.0" % Runtime
283
- )
283
+ ),
284
+ libraryDependencies += " com.lihaoyi" %% " os-lib" % " 0.8.1"
284
285
)
285
286
286
287
lazy val scala_strings = (project in file(" scala-strings" ))
Original file line number Diff line number Diff line change
1
+ package com .baeldung .scala .os
2
+
3
+ object OsApp extends App {
4
+ val ls = os.proc(" ls" , " -l" ).call()
5
+ println(ls.exitCode)
6
+ println(ls.out.text())
7
+ println(ls.err.text())
8
+
9
+ os.proc(" ls" , " -l" , " dir" ).call()
10
+
11
+ os.proc(" ls" , " -l" , " dir" ).call(check = false )
12
+
13
+ val lines = os.read(os.pwd / " LICENSE" ).linesIterator.size
14
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .scala .os
2
+
3
+ import scala .io .Source
4
+ import scala .sys .process ._
5
+
6
+ object ScalaSysApp extends App {
7
+ val output = " ls -l" .!!
8
+ println(output)
9
+
10
+ // This will print the standard output of the "ls -l command", even though we didn't ask for it!
11
+ val result = Seq (" ls" , " -l" ).!
12
+
13
+ val outputErr = " ls -l dir" .!!
14
+ val resultErr = " ls -l dir" .!
15
+
16
+ val source = Source .fromFile(" ./LICENSE" )
17
+ val lines = source.getLines.size
18
+ source.close()
19
+ }
You can’t perform that action at this time.
0 commit comments