title: java nio and FileInputStream
body: <p>Basically I have this code to decompress some string that stores in a file:</p>
  
  <pre><code>public static String decompressRawText(File inFile) {
      InputStream in = null;
      InputStreamReader isr = null;
      StringBuilder sb = new StringBuilder(STRING_SIZE);
      try {
          in = new FileInputStream(inFile);
          in = new BufferedInputStream(in, BUFFER_SIZE);
          in = new GZIPInputStream(in, BUFFER_SIZE);
          isr = new InputStreamReader(in);
          int length = 0;
          while ((length = isr.read(cbuf)) != -1) {
              sb.append(cbuf, 0, length);
          }
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          try {
              in.close();
          } catch (Exception e1) {
              e1.printStackTrace();
          }
      }
      return sb.toString();
  }
  </code></pre>
  
  <p>Since physical IO is quite time consuming, and since my compressed version of files are all quite small(around 2K from 2M of text), is it possible for me to still do the above, but on a file that is already mapped to memory? possibly using java NIO? Thanks</p>