I want escape certain characters in a string, for example changing \to \\ and newlines to '\n', and unicode encode the characters ifnecessary, for example \uXXXX, before saving it to a file. Is therea built in method in java that does this?