Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative for println in Scala

Tags:

scala

println

I am required to print huge amounts of data ( in the order of a few 100 MBs) on the console. Using println for this is failing miserably on IntelliJ. Is there any alternative like console.log which can handle and display this data without lagging and slowing down?

Thanks in advance!

like image 924
joanOfArc Avatar asked Jan 20 '15 11:01

joanOfArc


People also ask

What is Println in Scala?

Console implements functions for displaying the stated values on the terminal i.e, with print, println, and printf we can post to the display. It is also utilized in reading values from the Console with the function from scala. io. StdIn. It is even helpful in constructing interactive programs.

How do I print a function in Scala?

Method # 1: Using the “println” Command The “println” command in the Scala programming language is used to print a line while introducing a new line at the end. In this way, if you want to print more than one line, each of them will be printed on a separate line.


1 Answers

You can buffer, and perhaps bypass character encoding. It's also worth looking at the IntelliJ settings, particularly if you don't see this problem when running from the commandline - perhaps IntelliJ is offering some functionality in its console (e.g. highlight errors, link stack traces to line numbers) that involves scanning every line. You might also worry about word wrapping in your console

(That said, I'm not sure how you expect to understand anything from 100MB of printing - if it's something you need to look at an overview of to "see the pattern", try making code see the pattern the same way you do)

like image 117
lmm Avatar answered Oct 12 '22 14:10

lmm