Split on a back slash (\\)

I have a string that I am trying to split (string.split() ) and i want to “split” on a back slash to get the separate tokens of the string. How can I use the \ to split the string when the \ is a key character for the split and for regex?


String filePath = "c:\\\\documents and settings\\\\you\\\\desktop";
String[] fileParts = filePath.split("\\\\");

But with a little more research, the following code works…

String resultTokens = stringOfFilePath.split(“\\\\”);

You need to escape the “\” twice.