title: Why does it need & operation on byte value in BufferInputStream
body: <p><code>getBufIfOpen()[pos++] &amp; 0xff</code>, the value type of <code>getBufInOpen()</code> return is <code>byte</code>, which has been eight bits, why does it need <code>&amp; 0xff</code> here?</p>
  <p>Here are the source codes in <code>java.io.BufferedInputStream</code></p>
  <pre><code>
      /**
       * See
       * the general contract of the &lt;code&gt;read&lt;/code&gt;
       * method of &lt;code&gt;InputStream&lt;/code&gt;.
       *
       * @return     the next byte of data, or &lt;code&gt;-1&lt;/code&gt; if the end of the
       *             stream is reached.
       * @exception  IOException  if this input stream has been closed by
       *                          invoking its {@link #close()} method,
       *                          or an I/O error occurs.
       * @see        java.io.FilterInputStream#in
       */
      public synchronized int read() throws IOException {
          if (pos &gt;= count) {
              fill();
              if (pos &gt;= count)
                  return -1;
          }
          return getBufIfOpen()[pos++] &amp; 0xff;
      }
  
  
      /**
       * Check to make sure that buffer has not been nulled out due to
       * close; if not return it;
       */
      private byte[] getBufIfOpen() throws IOException {
          byte[] buffer = buf;
          if (buffer == null)
              throw new IOException(&quot;Stream closed&quot;);
          return buffer;
      }
  </code></pre>