title: Java how to copy part of a file
body: <p>I have to read a file and depending of the content of the last lines, I have to copy most of its content into a new file. Unfortunately I didn't found a way to copy first n lines or chars of a file in java.<br/>
  The only way I found, is copying the file using nio FileChannels where I can specifiy the length in bytes. However, therefore I would need to know how many bytes the stuff I read needed in the source-file.</p>
  
  <p>Does anyone know a solution for one of these problems?</p>