java 文件保存

来源:互联网 发布:英语电影观后感的软件 编辑:程序博客网 时间:2024/04/29 06:20

http://blog.csdn.net/ta8210/article/details/2073817


    private static void doCopy() throws Exception {
        int length = 2097152;
        FileInputStream in = null;
        FileOutputStream out = null;
        try{
            in = new FileInputStream(JobOperationTest.class.getResource(“”).getFile());
            out = new FileOutputStream("");
            byte[] buffer = new byte[length];
            int num =0;
            while((num=in.read(buffer))!=-1){
                out.write(buffer,0,num);  
            }
        } finally {
            try {  
                if(in!=null)  
                    in.close();  
                if(out!=null)  
                    out.close();  
            } catch (Exception ex) {
            }  
        }
    }
原创粉丝点击