There is just one issue with that. FileChannel (and RandomAccessFile, another class that could be used) both deal with bytes, not text. With simple ASCII files that isn't a big problem, but as soon as you get more exotic characters you will need proper encoding. I'm not sure how FileChannel can handle that. Perhaps it's possible using Charset / CharsetEncoder, where you take a CharBuffer or
String and convert it into a ByteBuffer first, which you then write to the FileChannel. There is one catch though - finding a safe place to start writing. What if the < of </body> is encoded in two bytes, with the first byte also being used for the previous character? (In other words, one byte contains data on two different characters.)