There are 2 levels of string interpretation, first the language parser makes it "\" , and that the regular expression engine sees and is invalid because it is an escape sequence without a character to be executed.
So, you need to use s.split("\\\\") so that the regex engine sees \\ , which in turn means literal \ .
If you define this string in a string literal, you should also avoid backslashes:
String s = "C:\\Program\\files\\images\\flower.jpg";
source share