title: How to read a file line by line with Java Stream
body: <p>I'm trying to read a long file line by line and trying in the same time to extract some information from the line.</p>
  
  <p>Here in an example of what i'm doing:</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import java.nio.file.Files;
  import java.util.stream.Stream;
  
  public class ReadFile_Files_Lines {
  
      public static void main(String[] pArgs) throws IOException {
          String fileName = "c:\\temp\\sample-1GB.txt";
          File file = new File(fileName);
  
          try (Stream&lt;String&gt; linesStream = Files.lines(file.toPath())) {
              linesStream.forEach(line -&gt; {
                  System.out.println(line);
              });
          }
      }
  }
  </code></pre>
  
  <p>One line in my file is devided into three part :</p>
  
  <pre><code>10 1010101 15
  </code></pre>
  
  <p>I'm looking to read those three informations every time.
  Like :</p>
  
  <pre><code>String str1 = line[0];
  String str2 = line[1];
  String str3 = line[2];
  </code></pre>
  
  <p>The solution i'm looking for will be better if i should not convert the stream to a collection.
  I will use those 3 String to create a graph data structure, something like : </p>
  
  <pre><code>createGraphe(str1,str2,str3);`
  </code></pre>
  
  <p>I know that i can send the full String, but as i'm learning Stream I'm interested to know how to extract those informations.</p>
  
  <p>Thank you.</p>