All I wanna do...

Started by
2 comments, last by Cliff_Robinson 21 years, 6 months ago
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".
Why yes, I will take the "FUSE".
Advertisement
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
Jacob Marner, M.Sc.Console Programmer, Deadline Games
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".
Why yes, I will take the "FUSE".
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.
Jacob Marner, M.Sc.Console Programmer, Deadline Games

This topic is closed to new replies.

Advertisement