Printing text with the Console class

When you’re using the System.out to print non-english characters you might have noticed that they’re translated to some odd characters that you didn’t intend to write.
In Java 6 there is a new Console class that can be retrieved by calling the System.console() method. That’ll give you access to an object that is capable of printing the characters to the console as you want to.
In the example below we write some typical characters that are messed up when using the System.out call.

The output from the code below is one line with completely different characters than intended and one line where the characters are displayed correctly.

Search for more Java info on this site here:
Custom Search

Please type any questions here.