- Java code
StringBuilder result = new StringBuilder(""); result.append("cmd /c "); result.append(" mysqldump "); result.append(" -h192.168.1.241 "); result.append(" -ukgoumovie "); result.append(" -p1qaz2wsx"); result.append(" --default-character-set=gb2312 "); result.append(" kgoumoviedb "); result.append(" tzl_medias "); result.append(" > "); result.append(" e:/tzl_medias.sql"); Process p = Runtime.getRuntime().exec(result.toString()); p.waitFor();
我数据库有数据,执行了后文件也有,但是是空文件,何解?
------解决方案--------------------------------------------------------
还是不要用
exec(String cmd)这个方法
用exec(String[] cmd)吧!
把命令里空格分隔的部分分别存在数组的每一项里做。
------解决方案--------------------------------------------------------
就是把你的命令一步一步做!而不是一起执行
------解决方案--------------------------------------------------------
应该可以!
------解决方案--------------------------------------------------------
应该是脚本问题,先单独在dos中执行看有没有文件
------解决方案--------------------------------------------------------
看是不是空文件
------解决方案--------------------------------------------------------