How would you write a Kotlin script that replace a...
# announcements
j
How would you write a Kotlin script that replace all occurrences of a string in a file, overwriting the file i.e. in-place like sed:
$ sed -e 's/find/replace/' -e 's/find/replace/' filename
m
If the file is not too big you can read it all into memory, replace occurrences and write it back as a whole. If the file is big and memory or cpu usage is a problem you should consider using http://docs.oracle.com/javase/8/docs/api/java/nio/MappedByteBuffer.html