2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Groovyで半角空白を含むコマンドを実行する方法

Posted at

コマンドと引数をStringListで用意してexecuteを呼び出すとOSに依存しないシェル実行が可能になる。
Stringと同様にListに対してもexecute系の機能が用意されている。
とは言っても、コマンド自体のパスについてはOS切り分けが必要になる場合が多い。(フルパスの場合は間違いなく切り分けが必要)

['C:/Program Files/Application 1/Program 1.exe', '-a', 'a 1'].execute()

ちなみにStringで、半角空白を含む部分を"などで自力で括ると、Windowsでは動くがMacOS Xでは動かないなどの事象が発生する。


GDK: java.util.List

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?