I want to take backup of database. I am using mysql databse and wamp server.For that i have written the following code.
Process runtimeProcess =Runtime.getRuntime().exec("C:\\wamp\\bin\\mysql\\mysql5.5.20\\bin\\mysqldump.exe -u root -pkarma dailyreport -r "+assign+"\\dailyreport.sql");
int processComplete = runtimeProcess.waitFor();
if(processComplete == 0)
{
JOptionPane.showMessageDialog(null, "Backup has been taken successfully", "BackUp", JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null, "Could not take backup", "BackUp", JOptionPane.INFORMATION_MESSAGE);
}
In above code String assign denotes the the path where i want to save the backup of database. But problem is that i am taking the location to save backup at runtime.and if I select path where folder name contains space it could not take backup because System does not getting the path as it contains space.Please help me how should i change the runtime.getruntime.exec() command.
Enclose the path in double quotes. That would help the shell see the entire argument as a single one instead of multiple arguments due to presence of space.