Archived

This topic is now archived and is closed to further replies.

All I wanna do...

This topic is 5537 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i''m writing a text adventure in Java, and all i wanna do is clear the console of text. That''s all. I''m looking for something like System.out.clearTheDamnScreen() I hate asking questions like this because it seems like I should be able to just look it up, but all my best efforts have been in vain. In the words of Leeloo from the Fifth Element, "Please Help"! Why yes, I will take the "FUSE".

Share this post


Link to post
Share on other sites
In Java (and most other languages for that matter) the console is not treated as a box of characters, but rather as a stream of characters. The advantage of this is that the same commands can be used for files too and data can be piped among applications.

So no, Java (and other languages that use the console) does not allow you to clear the screen with a single command. The closest you can get is write a lot of newlines and that will clear the screen (how many is needed depends on the size of the console).

Alternatively, you can make a Windowed program (with Swing, for instance) and then add a text box instead of using the console. In those you can can specify the exact size and also clear it and edit text in place.

Jacob Marner, M.Sc.
Console Programmer, Deadline Games

Share this post


Link to post
Share on other sites
Allright, thanks. I haven''t written a text game since my QBASIC days, and sometimes i forget how much more complicated the world has become. I think maybe I''ll get busy changing all those System.out.println() commands to drawString.

Why yes, I will take the "FUSE".

Share this post


Link to post
Share on other sites
Actually the concept of a console is much older than the text screen in QBASIC. Consoles as streams come all the way back from the time when output was written on ticker-tapes (or maybe before) - way before monitors - and just remain compatible with any kind of output today. The QBASIC screen, however, is made specifically for screens and nothing else in order to simplify things for the programmer.

Share this post


Link to post
Share on other sites