用什么替换路径中的空格字符? [英] Replace space characters in paths with what?

查看:244
本文介绍了用什么替换路径中的空格字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Java应用程序开始bash,我在我的路径中的命令执行内bash空间
(示例cd / Documents and Settings / test),我运行命令与Process Builder,但它不工作时路径有空格。我尝试用%20替换空格,但没有帮助。

I start bash from Java app and I have in my path for command which executes inside bash spaces ( example cd /Documents and Settings/test ), I run command with Process Builder but it doesn't work when path have spaces. I try to replace spaces with %20 but not help. What to do ?

推荐答案

您可以将完整路径封装为引号,例如:

You can either encapsulate the full path in quotion marks like this:

String quoted = "\"" + pathString + "\"";

或者,当您使用bash时,转义以下空格:

or, as you use bash, escape the spaces:

String escaped = pathString.replace(" ", "\\ ");

两者都应该作为 cd 命令。

这篇关于用什么替换路径中的空格字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆