Java IO流 之 FileWriter 以字符写入文件

http://www.verejava.com/?id=16994663236510

package com.io;

import java.io.*;

public class TestWriter
{
	public static void main(String[] args)
	{
		Writer writer=null;
		try
		{
			writer=new FileWriter(new File("res/writer_test.txt"));
			//向文件中写入数据
			String content="good morning";
			
			writer.write(content);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			try
			{
				writer.close();//关闭输出流
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}
	
}


http://www.verejava.com/?id=16994663236510

posted @ 2018-06-26 07:50  verejava  阅读(543)  评论(0编辑  收藏  举报