String dumpCommand = "C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqldump" + " -u " + user + " -p" + " " + database + " > " + path;
Runtime rt = Runtime.getRuntime();
File test = new File(path);
PrintStream ps;
try{
Process child = rt.exec(dumpCommand);
System.out.println("Child" + child);
ps = new PrintStream(test);
InputStream in = child.getInputStream();
int ch;
while ((ch = in.read()) != -1) {
ps.write(ch);
System.out.write(ch);
}
}
代码不起作用。它无限运行?如何在 java 上运行 mysqldump?