首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

资料字节流练习2

2012-09-06 
文件字节流练习2private static void copy(File upload,String destination){InputStream in nullOutpu

文件字节流练习2

private static void copy(File upload,String destination)    {        InputStream in = null;        OutputStream out = null;        try        {            File destination_file = new File(destination);                        if(!destination_file.exists())            {                destination_file.createNewFile();            }                                    in = new FileInputStream(upload);                        out = new FileOutputStream(destination_file);                        byte[] buffer = new byte[1024];            int count;            while((count=in.read(buffer))>0)            {                out.write(buffer, 0, count);            }        }        catch (Exception e)        {            e.printStackTrace();            try            {                in.close();                out.close();            }            catch (IOException e1)            {                e1.printStackTrace();            }        }    }

热点排行