Re: Console Output control

Discussion in 'Java' started by Sudsy, Aug 2, 2003.

  1. Sudsy

    Sudsy Guest

    Roger Varley wrote:
    > Hi
    >
    > I have a java program that runs from a Windows DOS prompt. It's reading in
    > an input file, re-formatting each record and writing out a new record. I
    > want to display something on the console to reassure my more impatient users
    > that the prgram is running and not frozen by displaying an incrementing
    > record count as each record is converted. So I want to print;
    >
    > System.out.println("Records converted = ");


    Don't try to mess with cursor positioning. Recall that there is
    an ASCII character called carriage-return. Imagine if you did
    something like this:

    do {
    System.out.print( "Records converted = " + index );
    System.out.flush();
    // process record and increment index
    System.out.print( "\r" );
    } while( test_for_end_condition );
    System.out.println();

    It should just keep rewriting the same line in the same place,
    save that the record number changes. Note that some O/Ss will
    interpret \r as a request for a \r\n combination so it's not
    truly portable. It works as expected on Linux but I don't
    make any representations as to how it might or might not
    work on M$ systems.
     
    Sudsy, Aug 2, 2003
    #1
    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. Ben Finney
    Replies:
    2
    Views:
    1,028
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    500
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    662
    Serge Terekhoff
    Jun 30, 2003
  4. pratap
    Replies:
    3
    Views:
    488
    James Kanze
    Jul 19, 2007
  5. Replies:
    5
    Views:
    3,473
    James Kanze
    Mar 4, 2008
Loading...

Share This Page