I have a String representing a directory, where \\ is used to separate folders. I want to split based on \"\\\\\":
\\
\"\\\\\"
String address = \"C
String#split() method takes a regex. In regex, you need to escape the backslashes. And then for string literals in Java, you need to escape the backslash. In all, you need to use 4 backslashes:
String[] splited = address.split("\\\\");