title: Reading newline char in java
body: <p>I am appending and streaming a bunch of files and I want to trim the header line after the first file. 
  On windows the following java code adds a blank line and I see garbled chars in notepad++. Any fixes/suggestions? Thank you.</p>
  
  <pre><code>    private int updateHeader(byte[] buffer) throws UnsupportedEncodingException {
        if (first) {
          return buffer.length;
        }
        String s, s2;
        s = new String(buffer, "UTF-8");
        int k = s.indexOf(System.getProperty("line.separator"), 0);
        s2 = s.substring(k + 1);
        byte[] buffer2 = s2.getBytes("UTF-8");
        System.arraycopy(buffer2, 0, buffer, 0, buffer2.length);
        return buffer2.length;
     }
  </code></pre>