Relative Content

Tag Archive for javafileunicoderead-writerandomaccessfile

Replace Unicode character with in a file using Random Access File class (JAVA)

I am trying to replace non keyboard characters in a file with space. I use FileReader class to validate each character & store invalid char positions. Then using RandomAccessFile class I do following:
file.seek(pos); file.write(" ".getBytes());
It seems like when it finds unicode characters of 2 or 3 bytes it still replaces it with one byte space. For eg. string like “€…Í” should be replaced with 3 spaces.
Is there better way to achieve this?
Thanks!