469,326 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

Clear screen

How would you clearn the screen in a console program???

Thanks
NeoPhreak >.<
Jul 17 '05 #1
4 72855

"NeoPhreak" <ad***@neophreak.com> wrote in message
news:vS*******************@news20.bellglobal.com.. .
How would you clearn the screen in a console program???


Console control is not Java's strong point. Generally there are three
approaches to this task:

* Use 'System.out.println' to write out enough space characters to
fill the screen [doesn't, however, provide very effective cursor
control :) !]

* If the console suports ANSI escape sequences, then the
following will do the trick:

final static String ESC = "\033[";
System.out.print(ESC + "2J"); System.out.flush();

* Use a JNI routine that makes the relevant OS system
call to perform this task. You should find these in
console-based libraries - do a search for JCurses or
any other Java-based Curses implementation

I hope this helps.

Anthony Borla

P.S.

Forget about your Java program responding to single keystrokes [i.e. without
the need to press ENTER]. Again, a suitable JNI routine or package like
JCurses is required
Jul 17 '05 #2
On Tue, 11 Nov 2003 16:52:45 -0500, "NeoPhreak" <ad***@neophreak.com>
wrote:
How would you clearn the screen in a console program???

Thanks
NeoPhreak >.<


Depends on the operating system... on Windows 9x and most flavors of
Unix (in a terminal window) you can use:

System.out.println(((char) 27)+"[2J"); // ANSI clear screen...

But NOTHING works in Windows NT. So you can write some JNI code, or
do something silly like:

for (int i=0; i<25; ++i) System.out.println();
Jul 17 '05 #3
Never did find a way to do that ...
cheers

"NeoPhreak" <ad***@neophreak.com> wrote in message
news:vS*******************@news20.bellglobal.com.. .
How would you clearn the screen in a console program???

Thanks
NeoPhreak >.<

Jul 17 '05 #4
http://www.xdweb.net/~dibblego/javafaq/javafaq.html#q30

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
"Denz" <RU*************@RUBBISHhotmail.com> wrote in message
news:tB******************@news-server.bigpond.net.au...
Never did find a way to do that ...
cheers

"NeoPhreak" <ad***@neophreak.com> wrote in message
news:vS*******************@news20.bellglobal.com.. .
How would you clearn the screen in a console program???

Thanks
NeoPhreak >.<


Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
reply views Thread by Peter | last post: by
6 posts views Thread by jcollins | last post: by
18 posts views Thread by Tim Mierzejewski | last post: by
6 posts views Thread by KL | last post: by
20 posts views Thread by ritchie | last post: by
22 posts views Thread by mp | last post: by
4 posts views Thread by John | last post: by
2 posts views Thread by nickyeng | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.