println vs System.out.println in Scala

Predef.println is shortcut for Console.println and you can use Console.setOut or Console.withOut for redirecting.

Also, Console.setOut only affects the current thread while System.setOut
affects the whole JVM. Additionally Scala 2.9 repl evaluates each line in its own thread, so Console.setOut is not usable there.

scala> val baos = new java.io.ByteArrayOutputStream
baos: java.io.ByteArrayOutputStream = 

scala> Console.withOut(baos)(print("hello"))

scala> println(baos)
hello

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)