How do I print escape characters in Java
<p>When I have a string such as:</p>

<pre><code>String x = "hello\nworld";
</code></pre>

<p>How do I get Java to print the actual escape character (and not interpret it as an escape character) when using System.out?</p>

<p>For example, when calling</p>

<pre><code>System.out.print(x);
</code></pre>

<p>I would like to see:</p>

<pre><code>hello\nworld
</code></pre>

<p>And not:</p>

<pre><code>hello
world
</code></pre>

<p>EDIT:
My apologies, I should clarify the question. I have no control over what 'x' is going to be, it may be a string I read from a file. I would like for x to retain its escape characters during normal program execution, but for debugging purposes I would like to see the actual escape characters.</p>

<p>Writing a method that subs each and every escape character seems overkill. Isn't there a better printing library other than PrintStream that does this for me?</p>

<p>If you're familiar with Ruby, think x.inspect()</p>
