陈华江(HuaChiang Chen) 陈泉冰专栏

未老之前携你远行...

FileOutputStream(文件输出流) 示例

//Demonstrate FileOutputStream
import java.io.*;
class FileOutputStreamDemo{
 public static void main(String[] args) throws Exception{
  String source = "Now is the time for all good men/n"
        +" to come to the aid of  their country/n"
        +" and pat their due taxes.";
  byte buf[] = source.getBytes();
  OutputStream f0 = new FileOutputStream("file1.txt");
  for(int i=0;i<buf.length;i+=2){
   f0.write(buf[i]);
  }
  f0.close();

  OutputStream f1 = new FileOutputStream("file2.txt");
  f1.write(buf);
  f1.close();

  OutputStream f2 = new FileOutputStream("file3.txt");
  f2.write(buf,buf.length-buf.length/4,buf.length/4);
  f2.close();
 }
}

阅读更多
个人分类: Java
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

FileOutputStream(文件输出流) 示例

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭