使用FileWriter向文本文件中写信息

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * 使用FileWriter向文本文件中写信息
 * 
 * @author Administrator
 * 
 */
public class FileWriterDemo {
	public static void main(String[] args) {
		// 1.创建流
		Writer wr = null;
		try {
			wr = new FileWriter("d:/简介1.txt",true);
			// 2.写入信息
			wr.write("我爱我的团队!");
			wr.flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			// 3.关闭流
			if (wr != null) {
				try {
					wr.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

	}
}

你可能感兴趣的:(I/O)