在Java中以编程方式清除控制台 [英] Clear The Console Programmatically In Java

查看:130
本文介绍了在Java中以编程方式清除控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个示例Java应用程序。我要清除窗口选项,例如:

I created a sample Java application. I want to clear the window options, i.e.:


  1. 注册

  2. 登录

  3. 清除

如果用户按3,我需要以编程方式清除所有选项。像 Console.clear

If the user presses 3 I need to programmatically clear all options. Something like Console.clear?

有什么方法可以用Java做到这一点吗?

Is there any way that I can do this with Java?

推荐答案

p>您将需要输出一堆空白行。即使在Windows / * nix中,清除/ cls并不会真正清除屏幕,它只是打印了足够的空白行,您看不到以前的文本。

You will need to output a bunch of blank lines. Even in Windows/*nix, clear/cls doesn't truly clear the screen, it just prints enough blank lines that you cannot see the previous text.

这篇关于在Java中以编程方式清除控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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