Java IO流 之 PrintWriter

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

package com.printstream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class TestPrintWriter
{
	public static void main(String[] args)
	{
		PrintWriter pw=null;
		try
		{
			pw=new PrintWriter(new FileWriter(new File("res/printwriter.txt"),true));
			pw.println(true);
			pw.println(20);
			pw.println("黎明");
			pw.flush();
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			pw.close();
		}
	}
}

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

你可能感兴趣的:(Java,编程基础)