It seems to be well-known and generic functionality, so it would be nice to have it in some well-known common place. Is *apache/commons-io* this place?
Here is the draft: https://github.com/DataFabricRus/textfile-utils This is my library made for DataFablic, it is written on kotlin with coroutines and Java NIO. Of course, it can be ported to java (preserving kotlin-version for multiplatform)