将字符流写入硬盘文件

代码如下:

import java.io.*;
public class TestOutputStream
{
 public static void main(String args[]) {
 
  try{
   
   OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("d://dat.txt"));
   osw.write("xqing");
   System.out.println(osw.getEncoding());
   osw.close();
   osw = new OutputStreamWriter(new FileOutputStream("d://dat.txt",true),"ISO8859_1");
   osw.write("xqing");
   System.out.println(osw.getEncoding());
   osw.close();
  } catch(Exception e) {
  
  }
 }
}

你可能感兴趣的:(java)