I tried to break the string into arrays and replace \ with \\ , but couldn’t do it, also I tried String.replaceAll something like this ("\","\\");.
I want to supply a path to JNI and it reads only in this way.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Don’t use
String.replaceAllin this case – that’s specified in terms of regular expressions, which means you’d need even more escaping. This should be fine:Note that the backslashes are doubled due to being in Java string literals – so the actual strings involved here are “single backslash” and “double backslash” – not double and quadruple.
replaceworks on simple strings – no regexes involved.