How to clear terminal/screen in scala

血红的双手。 提交于 2020-11-29 21:10:09

问题


I need to clear console screen in Scala

I've tried standard ANSI Clear screen which was suggested as "Terminal control/Clear the screen" by rosettacode.org here

object Cls extends App {print("\033[2J")}

I got following error:

Error:(8, 14) octal escape literals are unsupported: use \u001b instead
    println("\033[2J")

回答1:


I found solution for my question and I'll share it here for others, apparently from Scala 2.10 Octal litherals are deprecated see here. In question above "\033[2J" didn't work since Octal litherals were deprecated, so just listen to compiler and replace it with "\u001b[2J" as shown below:

object Cls extends App {print("\u001b[2J")}


来源:https://stackoverflow.com/questions/56608263/how-to-clear-terminal-screen-in-scala

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!