如下:
String[] cmd = { "date" };
String[] cmd = { "date '+%Y%m%d%H%M%S'" };
Process exec = Runtime.getRuntime().exec(cmd); 蓝色字体的命令执行没有问题
但是红色字体的命令执行完了,提示Cannot run program "date +%Y%m%d%H%M%S": error=2, No such file or directory
命令date +%Y%m%d%H%M%S在linux下是可以执行没有问题的呀?
那位大侠帮忙解答一下,谢谢。
String[] cmd = { "date" };
String[] cmd = { "date '+%Y%m%d%H%M%S'" };
Process exec = Runtime.getRuntime().exec(cmd); 蓝色字体的命令执行没有问题
但是红色字体的命令执行完了,提示Cannot run program "date +%Y%m%d%H%M%S": error=2, No such file or directory
命令date +%Y%m%d%H%M%S在linux下是可以执行没有问题的呀?
那位大侠帮忙解答一下,谢谢。
Runtime.getRuntime().exec(cmd);或者String cmd = "date '+%Y%m%d%H%M%S'";
Runtime.getRuntime().exec(cmd);