我的java代码在下面
String file = jFileChooser1.getSelectedFile().toString();
String cmd = "E:/XAMPP/mysql/bin/mysql.exe -u root < C:/Users/Admin/Documents/s.sql";
try {
Process cmdProcess = Runtime.getRuntime().exec(cmd);
int processState = cmdProcess.waitFor();
if (processState == 0) {
System.out.println("Sucess");
} else {
System.out.println("Error");
}
this.dispose();
} catch (IOException ex) {
System.out.println("Error : jewelleryshop.database.UploadDatabase.jFileChooser1ActionPerformed(): " + ex.getMessage());
} catch (InterruptedException ex) {
Logger.getLogger(UploadDatabase.class.getName()).log(Level.SEVERE, null, ex);
}
在Runtime.getRuntime().exec(cmd);
程序进入无限等待后执行此代码时。但同样的命令(即E:/XAMPP/mysql/bin/mysql.exe -u root < C:/Users/Admin/Documents/s.sql
)当我在CMD中给出它工作正常时。
我如何修改此代码以使其运行良好。