http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6550942
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4110242
===========Windows Okay========
import java.io.IOException;
public class aaaa {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
try {
//String cmd = "\"C:/Program Files/Internet Explorer/iexplore.exe\"";
String cmd = "C:/Program Files/Internet Explorer/iexplore.exe";
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}
}
=============Linux Error=========
import java.io.IOException;
public class aaaa {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
try {
//String cmd = "/PlusData/1 2/1.sh";
String cmd = "\"/PlusData/1 2/1.sh\"";
System.out.println(cmd);
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}
static boolean needsQuoting(String s) {
int len = s.length();
if (len == 0) // empty string have to be quoted
return true;
for (int i = 0; i < len; i++) {
switch (s.charAt(i)) {
case ' ':
case '\t':
case '\\':
case '"':
return true;
}
}
return false;
}
static String winQuote(String s) {
if (!needsQuoting(s))
return s;
s = s.replaceAll("([\\\\]*)\"", "$1$1\\\\\"");
s = s.replaceAll("([\\\\]*)\\z", "$1$1");
return "\"" + s + "\"";
}
}
==============================