1. 程式人生 > >java轉義字符處理——“\”替換為“/”

java轉義字符處理——“\”替換為“/”

file margin 獲取項目路徑 cto nic course getc 例如 tca

replaceAll("\\\\", "/");

例如

//獲取項目路徑,並將\轉換為/
File directory = new File("");

String courseFile = directory.getCanonicalPath().replaceAll("\\\\", "/");

註意String a="a\\b"

打印出來後變成a\b

java轉義字符處理——“\\”替換為“/”