How can I decode a large, multi-byte string file progressively in Java?
问题 I have a program that may need to process large files possibly containing multi-byte encodings. My current code for doing this has the problem that creates a memory structure to hold the entire file, which can cause an out of memory error if the file is large: Charset charset = Charset.forName( "UTF-8" ); CharsetDecoder decoder = charset.newDecoder(); FileInputStream fis = new FileInputStream( file ); FileChannel fc = fis.getChannel(); int lenFile = (int)fc.size(); MappedByteBuffer bufferFile