JFileChooser saver = new JFileChooser("./");
int returnVal = saver.showSaveDialog(this);
File file = saver.getSelectedFile();
BufferedWriter wt = null;
if (returnVal == JFileChooser.APPROVE_OPTION)
{
try
{
wt = new BufferedWriter( new FileWriter( file.getAbsolutePath()+".txt"));
wt.write( txtAsnortrule.getText());
wt.append("\r\n");
wt.flush();
wt.close( );
JOptionPane.showMessageDialog(this, "The text was saved complete",
"Done", JOptionPane.INFORMATION_MESSAGE);
}
catch (IOException e)
{
JOptionPane.showMessageDialog(this, "The text can not be save to file!",
"Error!", JOptionPane.INFORMATION_MESSAGE);
}
}