This article mainly introduces Java reading large files simple examples, the need for friends can refer to the
I'm going to extract useful data text files from a text file. 200 mb is it possible to build a cache to put useful data in a section of the proposed, what should I do? Java can use memory-mapped files to manipulate large files . max 2gb. Below is a simple example, more specific look at the Java API Docs or related data code is as follows: Import java.io.*; Import java.nio.*; import java.nio.channels.*; public class Largemappedfiles { static int length = 0X8FFFFFF; 128 mb public static void Main (string[] args) throws Exception { &NBSP;MAPPEDBYT Ebuffer out = new randomaccessfile ("Test.dat", "RW"). Getchannel () &N Bsp .map (FileChannel.MapMode.READ_WRITE, 0, length); for (int i = 0; i < length; i++) out.put ((Byte) ' x '); &NBSP;SYSTEM.OUT.PRINTLN ("finished writing"); for (int i = LENGTH/2 I < LENGTH/2 + 6; i++) &NBSP;SYSTEM.OUT.PRI NT ((char) out.get (i)); //read file } }///