Javaでcmdを実行し、パスの中にスペースが含まる問題の解決対策

対策1
public void startSeleniumServer(String params) {
String libPath="C:\\Program Files\\Wisc\\Boat\\Lib";
File f = new File(libPath);
command ="java -jar selenium-server-standalone.jar";
Process p = Runtime.getRuntime().exec(command, null, new File(libPath));
…..
}
対策2
String cmd = “cipher /e /a “+ “\"" + “C:\\Program Files" + “\"" “\\xxxx.properties";
Runtime.getRuntime().exec(cmd);

対策3
ファイルパスの書き方
String hfssPath = “C:\\AnsysHFSS15\\HFSS15.0\\Win64\\hfss.exe";
String hfssFile = " c:\\glaway\\Project2.hfss";
String command = “cmd /c start “+hfssPath.replaceAll(" “,"\" \"")+hfssFile;
String file = “c:\\Program Files\\Internet Explorer\\iexplore.exe";
String sysPath = “C:\\Program Files\\SystemVue2013.01\\bin\\SystemVue.exe";
String sysFile = " c:\\glaway\\tt.wsv";

Java

Posted by arkgame