日期:2014-05-20 浏览次数:20849 次
private JTextArea jtextarea;
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(baoq)){
String str=jtextarea.getText();
try {
FileWriter fw=new FileWriter("f:\\百度云\\源代码\\Textio\\Diary");
fw.write(str);
fw.close();
BufferedWriter bw = null;
try {
OutputStream os = new FileOutputStream("E:\\test.txt");
bw = new BufferedWriter(new OutputStreamWriter(os));
for (String value : textArea.getText().split("\n")) {
bw.write(value);
bw.newLine();//换行
}
} catch (IOException e1) {
e1.printStackTrace();
} finally {
if (bw != null) {
try {
bw.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}