java 转换流测试一

package org.lunzi.test.io;

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

public class TestTransForm1 {

public static void main(String[] args) {
try {
/**
* java.lang.Object
             *   java.io.Writer
             *     java.io.OutputStreamWriter
             *     字符流通向字节流的桥梁
*/

OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
"e:/org/test2.log"));
osw.write(
"test1");
    System.out.println(osw.getEncoding());
    osw.close();
    
    osw = new OutputStreamWriter(new FileOutputStream(
"e:/org/test2.log", true),"ISO8859_1");
osw.write(
"test2");
    System.out.println(osw.getEncoding());
    osw.close();
    
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

}

}

lunzi   2008-11-08 22:12:57 评论:1   阅读:703   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog