How to set system.out.print caret at the same position?

Discussion in 'Java' started by Camel, Jul 12, 2005.

  1. Camel

    Camel Guest

    Hello all,

    I have a console program that prints numbers. I want the newly printed
    number replace old number at the same position. How can do it?

    Thank you very much in advance.
    Camel, Jul 12, 2005
    #1
    1. Advertising

  2. Camel wrote:
    > I have a console program that prints numbers. I want the newly printed
    > number replace old number at the same position. How can do it?


    In general you can't. Java is not well suited for console/terminal
    emulator/text applications. You can consider to use a JNI-based library
    like JCurses to get more control over the console. Or you could play
    with the control codes for your particular terminal emulation.

    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
    Thomas Weidenfeller, Jul 12, 2005
    #2
    1. Advertising

  3. Camel

    Real Gagnon Guest

    > I have a console program that prints numbers. I want the newly printed
    > number replace old number at the same position. How can do it?


    Try to print a "backspace" character with something like

    System.out.print("\b");

    Bye.
    --
    Real Gagnon from Quebec, Canada
    * Looking for Java or PB code examples ? Visit Real's How-to
    * http://www.rgagnon.com/howto.html
    Real Gagnon, Jul 12, 2005
    #3
  4. Camel

    Camel Guest

    The System.out.print("\b") works.

    Thank you two very much.
    "Real Gagnon" <realgagnon_@_yahooSpamIsBadSstripunderscore.com> wrote in
    message news:Xns96916F6B93B5Frealhowtowwwrgagnonc@140.99.99.130...
    >> I have a console program that prints numbers. I want the newly printed
    >> number replace old number at the same position. How can do it?

    >
    > Try to print a "backspace" character with something like
    >
    > System.out.print("\b");
    >
    > Bye.
    > --
    > Real Gagnon from Quebec, Canada
    > * Looking for Java or PB code examples ? Visit Real's How-to
    > * http://www.rgagnon.com/howto.html
    Camel, Jul 12, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rf
    Replies:
    1
    Views:
    525
  2. Andy
    Replies:
    0
    Views:
    419
  3. cc

    Set caret position

    cc, Apr 4, 2005, in forum: Javascript
    Replies:
    4
    Views:
    208
    Csaba Gabor
    Apr 4, 2005
  4. R. Kangas
    Replies:
    0
    Views:
    171
    R. Kangas
    Jan 26, 2006
  5. brendan
    Replies:
    0
    Views:
    184
    brendan
    Aug 29, 2006
Loading...

Share This Page