如何清除Scala中的终端/屏幕 [英] How to clear terminal/screen in scala

查看:142
本文介绍了如何清除Scala中的终端/屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Scala中清除控制台屏幕

I need to clear console screen in Scala

我尝试了标准的ANSI透明屏幕,它由rosettacode.org 端子控制/清除屏幕" /Clear_the_screen#Scala"rel =" nofollow noreferrer>此处

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")}

我遇到以下错误:

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

推荐答案

我为我的问题找到了解决方案,我将在这里与其他人分享它,显然是从Scala 2.10开始.github.com/scala/bug/issues/5205"rel =" noreferrer>请参见此处.上面的问题"\ 033 [2J" 不起作用,因为不赞成使用八进制石制,所以请听编译器并用"\ u001b [2J" 替换它,如下所示下方:

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")}

这篇关于如何清除Scala中的终端/屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆