title: Take Strings from Text file and assign each line to value (2 at a time and insert into LinkedHashMap)
body: <p>What I'm trying to do is, load a Text file, then take the values from each line and assign them to a variable in my program. Every two lines, I will insert them into a <code>LinkedHashMap</code> (As a pair)</p>
  
  <p>The problem with a buffered reader is, all I can seem to do is, read one line at a time.</p>
  
  <p>Here is my current code: </p>
  
  <pre><code>public static void receiver(String firstArg) {// Receives
                                                  // Input
                                                  // File
      String cipherText;
      String key;
      String inFile = new File(firstArg).getAbsolutePath();
      Path file = new File(inFile).toPath();
  
      // File in = new File(inFile);
      try (InputStream in = Files.newInputStream(file);
              BufferedReader reader = new BufferedReader(
                      new InputStreamReader(in))) {
          String line = null;
  
          while ((line = reader.readLine()) != null) {
              // System.out.println(line);
              String[] arrayLine = line.split("\n"); // here you are
                                                      // splitting
                                                      // with whitespace
  
              cipherText = arrayLine[0];
              // key = arrayLine[1];
              System.out.println(arrayLine[0] + " " + arrayLine[1]);
  
              cipherKeyPairs.put(arrayLine[0], arrayLine[1]);
          }
      } catch (IOException x) {
          System.err.println(x);
      }
  </code></pre>
  
  <p>The problem is, it can't find the <code>arrayLine[1]</code> (for obvious reasons). I need it to read two lines at a time without the array going out of bounds.</p>
  
  <p>Any idea how to do this, so that I can store them into my <code>LinkedHashMap</code>, two lines at a time as separate values.</p>