Is there a standard API to check for line separators in Java?
<p>I'm using Java SE 6.</p>

<p>My program reads several kinds of files ranging from dos to unix and ascii to unicode, and I have to make sure that the line separators for the output file match the input files.</p>

<p>The way I do this is I read a sample line with BufferedReader read() function to search for the first line separator and save that line separator to a String. This way it can be used later whenever I need a new line.</p>

<p>I've inspected the Scanner class and noticed that possible line separators may include the following:</p>

<pre><code>\r\n
\r
\n
\u2028
\u2029
\u0085
</code></pre>

<p>Is there a library function to check for these characters? Or even better, is there already a library function to check what the input's line separator looks like?</p>

<p>Are there any other ways around this?</p>

<p>EDIT:
If possible I would like to use Java's standard API instead of 3rd party libraries, but all suggestions are most welcome.</p>

<p>EDIT:
Just to clarify.<br>
1) The input files do not depend on where this program is running. For example, if I'm running this program in Dos, I can still get a Unix input file.<br>
2) My goal is not to read each line delimited with line separators -- that's simple. What I really need is to write an output file with the same line separators as the input file. For example, if I'm running this program in Dos, and I get a Unix input file, I want to be able to write my output file with Unix line separators. This is why I'm asking if there's a standard API to detect line separators based on input files, rather than running OS.</p>

<p>Thanks.</p>
