Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

Basic Question

Thread view: 
Da Preetham - 16 May 2007 06:49 GMT
Hi guys, Im Preetham..
Im new to Java and I still learning how to make console programs...
I wanted to know the keyword for clearing the screen in java in a
console program...
Thanks in Advance.
Andrew Thompson - 16 May 2007 07:40 GMT
...
>Im new to Java and I still learning how to make console programs...

That is a good way to learn, but..

>I wanted to know the keyword for clearing the screen in java in a
>console program...

..note that Java is not well suited to doing 'advanced'
things with consoles.  It is probably better to
concentrate on learning the core Java classes,
and anytime you feel it is appropriate to clear
the console, do a loop of System.out.println("");
to print a number of blank lines.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Da Preetham - 17 May 2007 06:44 GMT
Thanks a lot

> ..
>
[quoted text clipped - 16 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200705/1
Robert Mark Bram - 16 May 2007 07:44 GMT
Hi Preetham,

> I wanted to know the keyword for clearing the screen in java in a
> console program...

There is no keyword or command for doing this, because Java doesn't
actually write to a console as such - it writes to an 'output stream',
with no understanding of whether that output stream is being displayed
on a console.. never mind what sort of console (dos, xterm etc).

Instead, what you could do is write enough empty lines to clear your
console:

for (int index = 0; index < 80; index++) {
  System.out.println("");
}

The biggest problem with this is how many times should you do it? If
you say "80", you should somehow make sure that all the other people
who are going to run your app have consoles that display 80 lines or
less.

Hope this helps.

Rob
:)
Da Preetham - 17 May 2007 06:48 GMT
Thanks Rob.
I have one more question. Which is better c++ or java on the basis of
game programming
Thanks in advanace,
Preetham.

On May 16, 11:44 am, Robert Mark Bram <robertmarkb...@gmail.com>
wrote:
> Hi Preetham,
>
[quoted text clipped - 23 lines]
> Rob
> :)
Joshua Cranmer - 16 May 2007 22:55 GMT
> Hi guys, Im Preetham..
> Im new to Java and I still learning how to make console programs...
> I wanted to know the keyword for clearing the screen in java in a
> console program...
> Thanks in Advance.

Try using:

System.out.println("\u001B[2J");

That should work in all ANSI-compliant consoles.
Da Preetham - 17 May 2007 06:48 GMT
Thanks for the info..
Ill try System.out.println("\u001B[2J");

> > Hi guys, Im Preetham..
> > Im new to Java and I still learning how to make console programs...
[quoted text clipped - 7 lines]
>
> That should work in all ANSI-compliant consoles.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.