Gee, if I can challenge a Bartender here :roll:
I'm assuming the Linux file separator is "/" or some other valid regex. From the API:
File.separator The system-dependent default name-separator character, represented as a string for convenience.
File.separator returns "\\" which is only a valid regex after you escape it with like "\\\\". The signature for ReplaceAll is:
public String replaceAll(String regex, String replacement)
The replacement is just a simple string. Admittedly, the reason we need all these backslashes (which can result in
LTS) is still the same and that is due to the multiple processing the Regex replacement engine must do on the String.
A good platform independent solution could be:
I use the File.separatorChar which is just a simple Char preceded by a backslash.
For Windows the resultant String passed is "\\\\".
For Linux the resultant String passed is "\\/".
Since there is nothing special of the '\/' sequence it is simply ignored and taken as '/'.
One more thing .... I tested it and it works