I\'m receiving a string from an external process. I want to use that String to make a filename, and then write to that file. Here\'s my code snippet to do this:
Try using the following regex which replaces every invalid file name character with a space:
public static String toValidFileName(String input) { return input.replaceAll("[:\\\\/*\"?|<>']", " "); }