Note that there are some explanatory texts on larger screens.

plurals
  1. PODo line endings differ between Windows and Linux?
    primarykey
    data
    text
    <p>I am trying to parse the Linux <code>/etc/passwd</code> file in Java. I'm currently reading each line through the <a href="https://docs.oracle.com/javase/9/docs/api/java/util/Scanner.html" rel="nofollow noreferrer"><code>java.util.Scanner</code></a> class and then using <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/String.html#split-java.lang.String-" rel="nofollow noreferrer"><code>java.lang.String.split(String)</code></a> to delimit each line.</p> <p>The problem is that the line:</p> <pre><code>list:x:38:38:Mailing List Manager:/var/list:/bin/sh" </code></pre> <p>is treated by the scanner as 3 different lines: </p> <ol> <li><code>list:x:38:38:Mailing</code></li> <li><code>List</code> </li> <li><code>Manager...</code></li> </ol> <p>When I type this out into a new file that I didn't get from Linux, <code>Scanner</code> parses it properly.</p> <p>Is there something I'm not understanding about new lines in Linux?</p> <p>Obviously a work around is to parse it without using scanner, but it wouldn't be elegant. Does anyone know of an elegant way to do it?</p> <p>Is there a way to convert the file into one that would work with <code>Scanner</code>?</p> <hr> <p>Not even two days ago: <a href="https://stackoverflow.com/questions/419291/historical-reason-behind-different-line-ending-at-different-platforms">Historical reason behind different line ending at different platforms</a></p> <p><strong>EDIT</strong></p> <p>Note from the original author:</p> <blockquote> <p><em>"I figured out I have a different error that is causing the problem. Disregard question"</em></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    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