Brad BARCLAY said:
If you're writing to an ANSI (or VT52/VT100/VT220/whatever) terminal
you should be able to do this by writing the correct line-control codes
to System.out. You'd have to put together the line control codes
yourself, and embed them into your output.
It is not the terminal control which is the problem here. It is
controlling the communication line (if you still have a physical line
running to that one terminal), e.g. setting it to 9600 baud, 7bit, odd
parity, two stop bits, and controlling your OS', e.g. setting a
terminal driver to not map NL to CR (or to map it), or getting fill
characters over the line if you have delays. Or, to make sure
System.in/out don't buffer.
Mind you, I don't know of any library that currently implements this.
A long time ago I started writing a pure Java library for terminal I/O
(using the old termcap format for terminal capability descriptions),
but gave up due to the lack of control one has over System.out, or any
other Reader/Writer/Stream. There was, e.g. no way to guarantee the
delays some real terminals need after they e.g. get a backspace or CR.
There was no way to ensure System.in/out are unbuffered, etc.
I am convinced that one needs JNI, or a library using JNI, to do any
kind of useful non trivial terminal I/O in Java.
/Thomas