File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Want to extend Console. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Want to extend Console." Watch "Want to extend Console." New topic
Author

Want to extend Console.

Nachiket Patel
Ranch Hand

Joined: Sep 16, 2007
Posts: 110
Hello,
I want to extend functionality of Java Console.
Say want to highlight(color) some words etc.

Is it possible???

As per my knowledge, it is not, because it is suppose to be platform independent. And not all platform provides this functionality (or something like that), but say i want to extend only console in windows (as of now)

How to do??

Any ideas???

Regards,
Nachiket


Before software can be reusable, it first has to be usable. - Ralph Johnson
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Would that be the public final class Console?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

In a completely platform independent way? No. But you can print ANSI escape codes to print colored text and do some cursor movement on Windows, Linux, and Mac OS X, so for all practical purposes yes, you can.

See here for a table of the escape codes you need. For a Java example: this prints "Hello, World" in red:

System.out.println("\u001b[01;31mHello, World\u001b[00m");


[Jess in Action][AskingGoodQuestions]
Nachiket Patel
Ranch Hand

Joined: Sep 16, 2007
Posts: 110
Hello,
Thank you for your replies.


Would that be the public final class Console?


I said i want to extend functionality not Console class.


Thanks, Ernest, that's what i am looking for. I want to show colored text, as well as folder navigation using <tab> feature.

I tried, but i don't know,
it prints like this..
←[01;31mHello, World←[00m

I'll try, but if you know, why it is not showing, then let me know.

Thanks
Nachiket
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42294
    
  64
There was some discussion on this recently: http://www.coderanch.com/t/416938/java/java/Different-colored-text


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to extend Console.