package io;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
/**
*
-
在流连接中使用PW
-
@author W
*/
public class PrintWriterDemo2 {
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
FileOutputStream fos = new FileOutputStream(“pw.txt”);
OutputStreamWriter osw = new OutputStreamWriter(fos,“GBK”);
BufferedWriter bw = new BufferedWriter(osw);
PrintWriter pw = new PrintWriter(bw);
pw.println(“我家来自黄土高坡!”);
pw.print(“你家来自哪啊?”);
System.out.println(“写出完毕!”);
pw.close();
}}