As there was a bit of confusion regarding the term "whitespace characters", I will attempt to cover both possible instances.
If you wish to display such things as new lines and tabs, Java Strings include special characters for these constructs. \n
will display a newline (line break). \t
will display a tab. \r
is a carriage return. There are others, as shown in the table here, but these are the most common.
Alternatively, if you intended displaying whitespace as a visible character, this is a different issue entirely. In this situation, I am assuming you wish to display a tab as an arrow or a space between words as a dot, like some text editors do. As far as I know, there is no built-in capability for this.
You could, however, replace existing whitespace with a unicode character that you want to represent that type of whitespace. The Java String
class supports the use of unicode characters; it would just be a matter of finding the one you wish to use to indicate, say, a tab and then replacing all instances of \t
with that symbol.