title: Can't print newline character (\n) in strings returned by String.split in Java
body: <p>I am writing a Java program in which a tab separated values (TSV) file containing two columns of information is read by a BufferedReader and then split into two components (which will serve as [key,value] pairs in a HashMap later in the program) using String.split("\t").  Let's say the first line of the TSV file is as follows:</p>
  
  <blockquote>
    <p>Key1\tHello world\nProgramming is cool\nGoodbye</p>
  </blockquote>
  
  <p>The code shown below would separate this line into "Key1" and "Hello world\nProgramming is cool\nGoodbye":</p>
  
  <pre><code>File file = new File("sample.tsv");
  BufferedReader br = new BufferedReader(new FileReader(file));
  String s = br.readLine();
  String[] tokens = new String[2];
  tokens = s.split("\t");
  </code></pre>
  
  <p>The problem now comes in trying to print the second string (i.e. tokens[1]).</p>
  
  <pre><code>System.out.println(tokens[1]);
  </code></pre>
  
  <p>The line of code above results in the second string being printed with the newline characters (\n) being ignored.  In other words, this is printed...</p>
  
  <blockquote>
    <p>Hello world\nProgramming is cool\nGoodbye</p>
  </blockquote>
  
  <p>...instead of this...</p>
  
  <blockquote>
    <p>Hello world<p>Programming is cool</p><p>Goodbye</p></p>
  </blockquote>
  
  <p>If I create a new string with the same text as above and use the String.equals() method to compare the two, it returns false.</p>
  
  <pre><code>String str = "Hello world\nProgramming is cool\nGoodbye";
  boolean sameString = str.equals(tokens[1]);    // false
  </code></pre>
  
  <p>Why can't special characters in the strings returned by String.split() be printed properly?</p>