Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Splitting the output console - possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Splitting the output console - possible?" Watch "Splitting the output console - possible?" New topic
Author

Splitting the output console - possible?

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Hi ranchers!
Is it possible to split the output console, say - in 2 parts, for updating each part separately?
Imagine 2 threads, each updating one of the parts.
Thanks!

PS: There shouldn't be any visual separation in between the parts!
An example:
23% **

Above, 23% is one part and * is another part. They will be continuously updated until they become:
100% **********
Hint: Progress bar.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Its possible. Write a program that uses C to write to VGA memory directly and then call the C code using JNI. Out of the scope of discussion of SCJP though.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
That's right on, John! That is, about the topic choice.
[ April 15, 2007: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Don't write to System.out, but to a buffering class, which handles the output.


http://home.arcor.de/hirnstrom/bewerbung
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Originally posted by Stefan Wagner:
Don't write to System.out, but to a buffering class, which handles the output.


Thanks for the help. You mean, without JNI? Please give me some more hints.
Some startup code would be more helpful.
Thanks again.
PS: Your signature made me laugh! Hehe..nice logic though.
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

And again, is it possible to see the real-time updates of the buffer?
Please look here:


A post related with this topic is
here.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You can try to send a bunch of backspace characters (0x08) to wipe out the current text, then rewrite it. That more or less works in Windows, don't know about *nix or any other environments.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Stan James:
You can try to send a bunch of backspace characters (0x08) to wipe out the current text, then rewrite it. That more or less works in Windows, don't know about *nix or any other environments.

\r works in Windows and Mac (which is Unix based). This is just a return -- you would then need to overwrite what was on that line. See how this looks...


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Faisal Pasha:
...A post related with this topic is
here.

Please don't cross-post.

I think you're making this overly complicated. Why would you use separate threads to update each "part" of the String? The numeric representation (23%) and the bar display (*****) are both based on the same value, so all you need is to build a String based on this value.
[ April 15, 2007: Message edited by: marc weber ]
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Yes - marc, I agree.

I had concentrated on this question, and didn't mention, that the real problem is to update the same line.
Your code is nice portable - this one:


needs Ansi.sys loaded on Windows, runs without any installation on most linuxes, and I don't know for mac, solaris, ...
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Thanks for your posts!
Could you please show output? Please reduce the value in for loop, to <100.
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Thanks a lot guys! Here is my output:



Note: I am not working in *nix. It's just fancy output!
Well, thanks a ton!
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Originally posted by marc weber:

\r works in Windows and Mac (which is Unix based). This is just a return -- you would then need to overwrite what was on that line. See how this looks...



Cool I learnt something new
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting the output console - possible?