Re: Clear Screen command



.. wrote:
On Sat, 28 May 2005, Frank Meyer wrote:


Chris,


   public void clearScreen()
   {
       final int NUM_LINES = 100; // Just to be safe
       for (int i = 0; i < NUM_LINES; i++) System.out.println();
   }

this does it - thanks :o)


If you don't have control over the number of lines on the display this is
not a good solution.

On my system my terminal console can be resized to have 160 lines of text.
This code would fail to clear the screen on my system. If my console was
somehow restricted to 100 lines then this would be an acceptable solution.

Bottom line, don't make assumptions. Whenever you see something like "Just
to be safe" it usually indicates that someone is making an assumption or
that the solution is not the best solution.

I'd use this solution for an in-house tool or something I whipped up for
personal use. I would not put this in something I shipped to a customer.


While that is true, perhaps there are better solutions:

1) Use a screen handling library like jcurses or jcurzez.
2) Ask the installer to specify a terminal type so you can send the right escape codes for the terminal in question.
3) Ask the installer to specify the escape code needed or the screen line limit.


W















.



Relevant Pages

  • Re: Idea for getting thread safety documented. Was: Re: Is ThreadPoolExecutor.execute() thread safe?
    ... just like all of the java.util.concurrent packages. ... required to specify its "MT-Level". ... MT-safe and can have multiple invocations executing concurrently - that's stronger than MT-safe, which could involve a lock which only lets one thread run it at once. ... I'm hazy on the difference between Safe and MT-Safe - it seems to just be some wishy-washy promises about concurrency. ...
    (comp.lang.java.programmer)
  • Re: Beware the Trojan !
    ... Infection occurs when viewing porn videos - I thought you were safe ... Please click here to download new version of codec. ... If the user has checked Open "Safe" Files After ... contains will launch Installer. ...
    (uk.comp.sys.mac)
  • Re: What are these files doing on my PC?
    ... These are not necessarily operating system patches, but could include Microsoft Office, Visual Studio and other programs that use the Windows Installer. ... If not, after a while, it may be safe to delete. ... 84514B.../ (a very long filename) ...
    (microsoft.public.windowsxp.general)
  • Re: Sum Query
    ... You don't say where you are posting from, but this is not a safe way to ... to specify a Jet-compatible date format explicitly: ... Eyeballing the final SQL statement makes it easy to pick up errors like ...
    (microsoft.public.access.modulesdaovba)
  • Re: mscoree.dll and GetFileVersionInfo
    ... Unless you do custom CLR hosting and specify version, isn't it safe to ... > Please reply only to the newsgroup. ...
    (microsoft.public.dotnet.framework.clr)