import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
public class IO_Writer {
public static void main(String[] args) {
Writer w = null;
try {
w = new FileWriter("a2.txt");
//写法一
/* String s = "IO is so easy";
char[] c = s.toCharArray();
w.write(c, 0, c.length);;
w.flush();
*/
//写法二
/* String s = "IO is so easy!!!";
w.write(s);
w.flush();
*/
//写法三
w.append("北京尚学堂欢迎您\r\n").append("IO is so easy");
w.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if(w != null)
w.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}