public void SaveScript() throws IOException
{
File file = null;
//save file dialog
static JFileChooser saveChooser = new
JFileChooser();
int result =
saveChooser.showSaveDialog(buttonScript);
if(result
==JFileChooser.APPROVE_OPTION)
{
saveChooser.addChoosableFileFilter(null);
file =
saveChooser.getSelectedFile();
String
filePath = file.getAbsolutePath();
filePath =
filePath.toString();
//get the
content from the scriptText which input with someone
inputValue =
scriptText.getText();
String[]
inputValues = inputValue.split(" ");
StringBuffer
inputValuesn = new StringBuffer();
for (String
x: inputValues){
inputValuesn.append(x
+ " ");
}
outPut(filePath,inputValuesn.toString());
}
}
//the action of savescript
public void actionPerformed(ActionEvent e)
{
if (e.getSource() ==
buttonScript){
try {
SaveScript();
} catch
(IOException e1) {
//
TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
public void outPut(String path, String s) {
File file = new File(path);
try {
PrintWriter out = new PrintWriter(file);
out.write(s);
out.flush();
System.out.println("OK...");
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}