Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I haven't read the rest of your code yet, but this is already inaccurate:</p> <pre><code>//"If you write \r\n on Windows, you'll actually get 0x0D 0x0D 0x0A in the file" byte[] CRLF = { 0x0D, 0x0D, 0x0A }; </code></pre> <p>CRLF is just 0x0d, 0x0a...</p> <p>Additional problems:</p> <ul> <li>You're using <code>String.getBytes()</code> without specifying an encoding: almost always a bad idea</li> <li>You're not using <code>finally</code> blocks for your streams</li> <li>You're using <code>""+x</code> to convert a value to a string - just call <code>toString</code> (in the case of <code>header</code> you've already <em>got</em> a string); <code>""+x</code> will work, but it's ugly code - it talks about concatenation, which isn't what you're trying to achieve.</li> <li>You should use a <code>Writer</code> (e.g. <code>OutputStreamWriter</code>) to write text data - that's what it's there for. Then you don't need to worry about the bytes, you can just work in terms of strings. I would strongly suggest <code>OutputStreamWriter</code> instead of <code>FileWriter</code> so that you can specify the encoding.</li> </ul> <p>Once you've fixed all that, your code will be in a better position to fix the specific problem of line breaks... although I'd strongly recommend that if you're still having problems, you ask a question with a short but <em>complete</em> program which <em>just</em> prints a few lines of text. The header, footer etc are irrelevant to the business of "writing a line separator".</p> <p>You may well find that the IO-related classes in <a href="http://guava-library.googlecode.com/" rel="nofollow">Guava</a> make all of this easier, too...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload