Extract Sub Sequence from a file - Java - quick way

I have a large file that contains a sequence of characters such as "ABCDEabcde ..... XYZxyz". Now I want to extract some subsequences. Say, for example, from the 10th character to the 50th character, from the 15th character to the 55th character (all subsequences are the same length, and the starting position always increases). Can someone help me how to do this quickly in Java?

0
source share
2 answers

Why not try something like this:

BufferedReader br = new BufferedReader(new FileReader(<FileName>), int size);

Just enter the size of the buffer and continue to check yours subStringsonly in this piece. If nothing is found, drop it and go to the next snippet.

0
source

MappedByteBuffer

http://docs.oracle.com/javase/7/docs/api/java/nio/MappedByteBuffer.html

RandomAccessFile raf = new RandomAccessFile(....);
FileChannel fc = raf.getChannel();

MappedByteBuffer mmap = fc.map(READ_ONLY, 0, fc.size() );
0

All Articles