反斜杠替换为java路径

时间:2016-02-04 09:09:42

标签: java

我有这条道路:

 /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

我需要options.setBinary。问题是由于反斜杠,我的java中出现了错误,但那是我的道路!

我也试着用这个:

 String newString = text.replace(...);

但是如果我添加新字符串

,我的命令需要一个路径并发送错误
 options.setBinary(" /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome ");

我该怎么办?

2 个答案:

答案 0 :(得分:2)

假设您的路径保存为String:

这是因为你export class PicutrePage { constructor(app: IonicApp, nav: NavController, params: NavParams, NgZone zone) { this.nav = nav; this.thumbnail = 'img/placeholder.png'; this.zone = zone; } 。尝试将其替换为\,它应该有效。

答案 1 :(得分:0)

试试这个:

NLS_DATE_FORMAT

更新的答案

@Tom和@Erwin Bolwidt评论波纹路径应该改为(对于mac os):

 options.setBinary(new File("/Applications/Google/Chrome.app/Contents/MacOS/Google/Chrome"));