记事本的另存为是通过输出流实现的。
JFileChooser chooser=new JFileChooser();//创建文件选择器
int result=chooser.showSaveDialog(null);//弹出一个save file文件选择器对话框
if(result==JFileChooser.APPROVE_OPTION) {//JFileChooser.APPROVE_OPTION是个整数常量,代表0
try {
//向磁盘中写文件
FileWriter fout=new FileWriter(chooser.getSelectedFile(),true);//创建文件输出流对象
//写数据
String string=area.getText();
fout.write(area.getText()+"\r\n");
fout.close();//关闭流,释放IO流所占的系统资源
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
希望可以帮到你。