title: java split large files into smaller files while splitting the multiline record without breaking the record in incomplete state
body: <p>I have a record split into multiple lines in a file. Only way to identify the end of the record is when new record starts with ABC. Below is the sample. File size could be 5-10 GB and I am looking for a efficient java logic ONLY to split the files(no need of reading every line), but splitting logic should a check to start a new file with new record, which should start with &quot;ABC&quot; in this case.</p>
  <p>Added few more details, I am just looking for splitting the file and while splitting the last record should be ended correctly in a file.</p>
  <p>Can someone please suggest?</p>
  <pre><code>HDR
  ABCline1goesonforrecord1   //first record 
  line2goesonForRecord1      
  line3goesonForRecord1          
  line4goesonForRecord1
  ABCline2goesOnForRecord2  //second record
  line2goesonForRecord2
  line3goesonForRecord2
  line4goesonForRecord2
  line5goesonForRecord2
  ABCline2goesOnForRecord3     //third record
  line2goesonForRecord3
  line3goesonForRecord3
  line4goesonForRecord3
  TRL
  
  </code></pre>