Firstly, I'm sorry about my English.
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: http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ314_029.htm
My purpose is read the data in the buffer, and then using regular expression.
DumpFilePath file size is about 4 GB.
public static List<String> anaysis_main(String pattern_string) throws IOException {
List<String> result = new ArrayList<String>();
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;
}
Any ideas?