Replace whitespace on the way?

I run bash from a Java application, and I have my own path for a command that runs inside bash spaces (cd / Documents and Settings / test example), I run a command with Process Builder, but it does not work when the path has spaces. I am trying to replace spaces with% 20, but it will not help. What to do?

+3
source share
4 answers

You can encapsulate the full path in quotation marks as follows:

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

or when you use bash, avoid spaces:

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

Both should work as an argument for your team cd.

+9
source

encapsulate all the way between quotes.

cd "/Documents and Settings/test"
+4
source

%20 , URL. String [] List [] String, , , cmd.

,

"cd", "/Documents and Settings/test"

. Java , . script ( ) Java.

+3

, bash. cd/Document Settings/ . cd C:Documents\ and\ Settings, .

. bash , C: . just/ cygwin .

+3

Source: https://habr.com/ru/post/1786659/


All Articles