title: Reading Huge Data With Java
body: <p>Firstly, I'm sorry about my English.</p>
  
  <p>I looking for an effective a way to read a Big file in java. I make a log analysis program and I have log files at least from 500 MB to 4 GB. I have tried the Filechannel class (Memory Mapped files), but I could not get effective result. Take a look here: <a href="http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ314_029.htm" rel="nofollow">http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ314_029.htm</a></p>
  
  <p>My purpose is read the data in the buffer, and then using regular expression.</p>
  
  <p>DumpFilePath file size is about 4 GB.</p>
  
  <pre><code>public static List&lt;String&gt; anaysis_main(String pattern_string) throws IOException {
  
      List&lt;String&gt; result = new ArrayList&lt;String&gt;();
      Pattern pattern = Pattern.compile(pattern_string, Pattern.CASE_INSENSITIVE);
  
  
      File file = new File(DumpFilePath);
  
      RandomAccessFile raf = new RandomAccessFile(file,"rw");
      String line = null;
      raf.seek(0);
  
  
      int i = 0;
  
      while((line=raf.readLine())!=null)
      {
          Matcher matcher = pattern.matcher(line);
          while (matcher.find())
          {               
              result.add(matcher.group(1));
          }
      }
      raf.close();
  
      return result;
  }
  </code></pre>
  
  <p>Any ideas?</p>