title: How do I preserve line breaks when using jsoup to convert html to plain text?
body: <p>I have the following code:</p>
  
  <pre><code> public class NewClass {
       public String noTags(String str){
           return Jsoup.parse(str).text();
       }
  
  
       public static void main(String args[]) {
           String strings="&lt;!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN \"&gt;" +
           "&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;&lt;/TITLE&gt; &lt;style&gt;body{ font-size: 12px;font-family: verdana, arial, helvetica, sans-serif;}&lt;/style&gt; &lt;/HEAD&gt; &lt;BODY&gt;&lt;p&gt;&lt;b&gt;hello world&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;b&gt;yo&lt;/b&gt; &lt;a href=\"http://google.com\"&gt;googlez&lt;/a&gt;&lt;/p&gt;&lt;/BODY&gt; &lt;/HTML&gt; ";
  
           NewClass text = new NewClass();
           System.out.println((text.noTags(strings)));
  }
  </code></pre>
  
  <p>And I have the result:</p>
  
  <pre><code>hello world yo googlez
  </code></pre>
  
  <p>But I want to break the line:</p>
  
  <pre><code>hello world
  yo googlez
  </code></pre>
  
  <p>I have looked at <a href="https://jsoup.org/apidocs/org/jsoup/nodes/TextNode.html#getWholeText--">jsoup's TextNode#getWholeText()</a> but I can't figure out how to use it.</p>
  
  <p>If there's a <code>&lt;br&gt;</code> in the markup I parse, how can I get a line break in my resulting output?</p>