Possible Duplicate:
Replace all occurrences of substring in a string – which is more efficient in Java?
I’m trying to replace all occurrences of \t (tab) with four spaces in a file.
I’ve been searching for a while but couldn’t find anything useful.
I found out that I need to create a temporary file.
there is a function for this called replace
to do this with a file create a temp file and open a FileWriter for it
open a FileReader for the original file
the in a loop call
readln(), check for null,replace("\t"," ")andwriteon the appropriate objectsthen close the reader and writer and
delete()the original file andrename()the temp file to the original file