java - Replace backslash with forward slash -


i have following path: com/teama/merc/test/restest , want convert this: com\teama\merc\test\restest

i trying append above path path: c:\users\toby\git\mercury\mercury\ str.replace('/', '\\'); when append both of strings together, output: c:\users\toby\git\mercury\mercury\com/teama/merc/test/restest

here code in question:

    string home = system.getproperty("user.dir");     path.replace('/', '\\');     system.out.println(path);      string folder = home + file.separatorchar + path;     system.out.println(folder);      file file = new file(folder);     if(file.isdirectory())     {         system.out.println(file.getpath() + " directory");     } 

the appended path not seen folder because of slashes. help?

edit: clarify, full path (both strings appended) infact folder.

in java, string's aren't mutable, when change them replace method, have reassign variable changed string. so, have change replace code this:

path = path.replace('/', '\\'); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -