我在以下代码中遇到两个问题
File export=new File("C:\\testdir"+jComboBox2.getSelectedItem().toString()+"\\export.bat");
try
{
FileUtils.write(export, "mini_server_11\\udrive\\bin\\mysqldump -u root -proot static_gatetest > C:\\testdir"+jComboBox2.getSelectedItem().toString()+"\\admin.sql", false);
}
catch (IOException ex)
{
JOptionPane.showMessageDialog(this, "Unable to create file");
Logger.getLogger(adminsetting.class.getName()).log(Level.SEVERE, null, ex);
return;
}
//Execute bat file
try
{
Desktop.getDesktop().open(export);
}
catch (IOException ex)
{
JOptionPane.showMessageDialog(this, "Unable to launch file");
Logger.getLogger(adminsetting.class.getName()).log(Level.SEVERE, null, ex);
return;
}
try
{
//Delete bat file. No worries. this file will be overwritten when next attempt
//to build installer takes place
FileUtils.forceDelete(export);
}
catch (IOException ex)
{
Logger.getLogger(adminsetting.class.getName()).log(Level.SEVERE, null, ex);
}
我正在使用Apache Common IO来动态创建批处理文件。
我对缩进问题表示歉意。我仍然无法弄清楚如何在SO中正确编写代码