1、文件输入输出流

package com.hanqi;

import java.io.*;


public class FileTest {

    public static void main(String[] args) throws IOException {
        
        File file=new File("D:/mywork","work.txt");

        try {
            FileOutputStream out=new FileOutputStream (file);
            
            byte buy[]="明日科技 JAVA部".getBytes();
            
            out.write(buy);
            
            out.close();
            
            
        } catch (FileNotFoundException e) {
        
            e.printStackTrace();
        }
        FileInputStream in=new FileInputStream(file);
        
        byte byt[]=new byte[1024];
        
        int len=in.read(byt);
        
        System.out.println("文件中的信息是:"+new String(byt,0,len));
        
        in.close();
    }

}

文件中的信息是:明日科技 JAVA部

posted on 2016-01-26 11:54  悠悠小花  阅读(151)  评论(0编辑  收藏  举报