我試圖用java(Android)中的'/'
替換'\\'
,這似乎不起作用!在Java中用「/」替換「\」
String rawPath = filePath.replace("\\\\", "/");
這是什麼問題?我已經逃脫了「\」並嘗試轉義'/',但沒有用。原始字符串沒有任何反應。
filePath = abc\\xyz(not after escaping two \\, the original string is with two \\)
rawPath = abc \ xyz
expected = abc/xyz
這樣做的正確方法是什麼? (另一個Windows文件到Android路徑轉換概率)
爲什麼不在整個代碼中使用'java.io.File.separator'? – 2012-07-16 17:38:56
是的 - 切換到這個,只是現在測試一些東西,跑到這裏,謝謝! – Slartibartfast 2012-07-16 17:45:12