Am expecting the url to be C\:test but it's coming as C:test
If I add String url="C:\\\\test"; then its working fine. But in my case am getting this url dynamically from another class. So I can't go for this option. Please help me.
Joined: Oct 08, 2008
Can I try like this. This is working fine. But I guess it's a worst option.
Joined: Oct 13, 2005
Far better to use a StringBuilder for that sort of manipulation. You can iterate through the String, look for an instance of \ and insert a \\ character after it. Just make sure to increment your index after the insertion, otherwise you will get strings with look like th\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\is