title: Reading an ASCII file with FileChannel and ByteArrays
body: <p>I have the following code:</p>
  
  <pre><code>        String inputFile = "somefile.txt";
          FileInputStream in = new FileInputStream(inputFile);
          FileChannel ch = in.getChannel();
          ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE);  // BUFSIZE = 256
  
          /* read the file into a buffer, 256 bytes at a time */
          int rd;
          while ( (rd = ch.read( buf )) != -1 ) {
              buf.rewind();
              for ( int i = 0; i &lt; rd/2; i++ ) {
                  /* print each character */
                  System.out.print(buf.getChar());
              }
              buf.clear();
          }
  </code></pre>
  
  <p>But the characters get displayed at ?'s.  Does this have something to do with Java using Unicode characters?  How do I correct this?</p>