File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Splitting the output console - possible?

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right on, John! That is, about the topic choice.
[ April 15, 2007: Message edited by: Barry Gaunt ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't write to System.out, but to a buffering class, which handles the output.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 355
Chrome Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 355
Chrome Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your posts!
Could you please show output? Please reduce the value in for loop, to <100.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic