title: How to use System.in.read() in java?
body: <p>I need to input and load some chars in a boolean 2-D array. If the char is <code>X</code>, mark the array element as <code>true</code>; else if the char is <code>.</code>, mark the array element as false. </p>
  
  <p>Here is my design:</p>
  
  <pre><code>boolean[][] Array = new boolean[2][2];
  
  for (int i = 0; i &lt; 2; i++) {  
     for (int j = 0; j &lt; 2; j++) {
          if (System.in.read() == '.') {
              Array[i][j] = false;
          } else if (System.in.read() == 'X') {
              Array[i][j] = true;
          }
      }
  }
  </code></pre>
  
  <p>And, for example, if I type in <code>....</code> or <code>XXXX</code>, it does not produce the correct result. Also for other input the result is not correct. </p>
  
  <p>So how to deal with this?</p>