利用字节流类FileOutputStream写文本文件

import java.io.*;
import java.io.OutputStream;
public class FileInputStreamTest {
 public FileInputStreamTest() {
 }
 public static void main(String[] args) throws IOException {
      try {
           String str = “好好学习Javarn”;
           byte[] words = str.getBytes();
           OutputStream fos = new FileOutputStream(“d://text.txt”,true);
           fos.write(words, 0, words.length);
           System.out.println(“text文件已更新!”);
           fos.close();
      } catch (Exception e) {
      System.out.println(“创建文件时出错!”);
   }
 }
}

发表评论