1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public void saveDB()
{
dialogPath = new JFileChooser();
dialogPath.showSaveDialog(null);
String fileURL = dialogPath.getSelectedFile().getPath();
sauvegardePass passRead = new sauvegardePass();
String pass = passRead.lireFichier();
try{
Process p = Runtime.getRuntime().exec("\"C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqldump.exe\" -u root -p"+ pass + " listecd");
File sqlDump = new File(fileURL);
FileWriter fw=null;
try
{
fw = new FileWriter(sqlDump);
}
catch (IOException ex)
{
}
InputStream in = p.getInputStream();
InputStreamReader xx = new InputStreamReader(in,"utf8");
char[] chars=new char[1024];
int ibyte=0;
while((ibyte=xx.read(chars))>0)
{
fw.write(chars);
}
fw.close();
}
catch(Exception e)
{
System.out.println("dump = " + e);
}
} |
Partager