IO 흐름 - 흐름 전환 버 프 레 드 라이터

832 단어 자바
package com.io.ioDemo;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 *        
 * @author Administrator
 *
 */
public class OutputStreamWriterDemo {
	public static void main(String[] args) {
		BufferedWriter bw = null;
		try {
			//1.    2.    :  
			bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("c:\\osw.txt")),"utf-8"));
			bw.write("123");
			bw.write("  ");
			bw.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally {
			try {
				bw.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}

좋은 웹페이지 즐겨찾기