public static final String SEPARATOR = System.getProperty("file.separator"); String code = "test.foo.bar"; String fix = code.replaceAll("\\.", SEPARATOR);
I'm keep getting a StringIndexOutOfBoundsException. If I replace SEPARATOR with "\\\\" then it'll work as I want. Is there a safe way to replace the periods with the file separator associated with the system property?