title: Parsing a file with single and multi-lines of data
body: <p>I have a text file dump that I need to convert to a delimited file. The file contains a series of "records" (for lack of a better word) formatted like this:</p>
  
  <pre><code>User: abc123 
  Date: 7/3/12
  Subject: the foo is bar
  Project: 123456
  Problem: foo bar in multiple lines of text
  Resolution: foo un-barred in multiple lines of text
  
  User: abc123 
  Date: 7/3/12
  Subject: the foo is bar
  Project: 234567
  Problem: foo bar in multiple lines of text
            which may include &lt;newline&gt; and 
            extend to multiple lines of text
  Resolution: foo un-barred in multiple lines of text
  
  ...
  </code></pre>
  
  <p>Right now, with Java, I'm using StringBuffer to read this file line-by-line, parsing the lines to individual fields based on a series of <code>if(inputLine.toLowerCase().startsWith("user:"))</code> logic to output a final delimited line to a text file.</p>
  
  <p>However, the fields <code>Problem</code> and <code>Resolution</code> are free form and <em>may</em> be multi-line. I'm trying to do something that would create two Strings: append all lines following <code>Problem:</code> and ending at <code>Resolution:</code> and append all lines starting after <code>Resolution:</code> and ending at <code>Form:</code>.</p>
  
  <p>I've alerady viewed <a href="https://stackoverflow.com/questions/2509170/is-there-an-easy-way-to-concatenate-several-lines-of-text-into-a-string-without">this link</a> and <a href="https://stackoverflow.com/questions/878573/java-multiline-string">this link</a>, which suggest that <code>StringBuilder</code> might be an appropriate way to do this...however, I'm not quite sure how to construct the logic. </p>
  
  <p><strong>EDIT:</strong>
  Since I'm reading line-by-line, I'm having a hard time wrapping my head around how to code</p>
  
  <pre><code>&lt;pseudocode&gt;
  If the line starts with "Problem" extract the charactes after "Problem" else
  if the PRIOR line starts with "problem" and the current line doesnt start with "resolution" then append characters in line to prior line
  etc.
  &lt;/pseudocode&gt;
  </code></pre>
  
  <p>but then, if there's a third line of "Problem...? I just can't visualize how to make it work.</p>
  
  <p>Any ideas or alternate methods of achieving my desired results?</p>