I’m new to the NIO classes; I’m working on some pattern matching with (possibly) very large text files, and so far I’m reading data in from the file by mapping its channel to a byteBuffer, which is then converted to a charBuffer. My question is, with the charBuffer’s MapMode set to READ_WRITE, is there a way to directly modify the charBuffer as I am processing it, ala matcher.replaceAll()? Or do I need to loop through with matcher.find() and manually replace each instance of the pattern?
Share
I would first just try reading in the entire file and do a find and replace and see if the performance is acceptable. If not, try to read in enough of the text to create a match and then do a replace on that portion of the text. Depending on the pattern/performance you may need to write a custom parser instead.