Forums Register Login

split() throws PatternsyntaxException

+Pie Number of slices to send: Send
hi ranchers,

i have a String of a location like "dir\\filename" .I want to separate the directory name from file name for which i use the following code



But it throws PatternsyntaxException. why ? it seems to me that split() having a problem with "\\".
+Pie Number of slices to send: Send
\ is a special character in Java string literals and in regular expressions. Which means you have to escape it twice!
+Pie Number of slices to send: Send
bingo !!
thanks Matthew Brown
1
+Pie Number of slices to send: Send
you could also consider using FILE, that has loads of methods to do this sort of stuff.
A tiny monkey bit me and I got tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 768 times.
Similar Threads
about criteriaFind
PatternSyntaxException
I'm Confused : How does this work
replaceAll("+"," ")
char cannot be dereferenced
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:08:01.