java 新建文件夹保存
String Txtname = field.getText();
File file3 =new File("D:\\MATP_robot"+"\\"+ Txtname);
//如果文件夹不存在则创建
if (!file3 .exists() && !file3 .isDirectory())
{
System.out.println("//不存在");
file3 .mkdir();
} else
{
System.out.println("//目录存在");
}
File file = new File(".\\config\\batfolder\\Matp.bat");
if (file.exists()) {
file.delete();
}
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(
".\\config\\batfolder\\Save.bat", true));
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
writer.write("echo off" + "\r\n");
writer.write("copy .\\config\\shutter_button.txt "+ "D:\\MATP_robot"+"\\"+Txtname
+ "\r\n");
writer.flush();
writer.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
RAMThreadOn mRAMThreadOn = new RAMThreadOn();
mRAMThreadOn.run();
String Txtname2 = field2.getText();
File f = new File("D:\\MATP_robot\\"+"\\"+Txtname+"\\"+"shutter_button.txt");
System.out.println(f);
f.renameTo(new File("D:\\MATP_robot\\" + "\\"+Txtname+"\\" + Txtname2 + ".txt"));
System.out.println(f + "========11========");
JOptionPane.showMessageDialog(null, "脚本保存在D:\\MATP_robot"+"\\"+Txtname+"目录中");
field2.setText("");
}
field.selectAll();
// 隐藏对话框
setVisible(false);