java学习笔记之转换流

举例子:

 1 import java.io.*;
 2 public class TestTransForm1 {
 3   public static void main(String[] args) {
 4     try {
 5       OutputStreamWriter osw = new OutputStreamWriter(
 6            new FileOutputStream("d:\\bak\\char.txt"));
 7       osw.write("mircosoftibmsunapplehp");
 8       System.out.println(osw.getEncoding());
 9       osw.close();
10       osw = new OutputStreamWriter(
11                                       new FileOutputStream("d:\\bak\\char.txt", true),
12                                       "ISO8859_1"); // latin-1
13       osw.write("mircosoftibmsunapplehp");
14       System.out.println(osw.getEncoding());
15       osw.close();
16     } catch (IOException e) {
17       e.printStackTrace();
18     }
19   }
20 }

 

posted @ 2015-02-11 10:29  董文博  阅读(113)  评论(0编辑  收藏  举报