Home 文章 Java基础 java:实现文件复制

feedsky
抓虾
google reader
my yahoo
java:实现文件复制 E-mail
User Rating: / 0
PoorBest 
作者是 Administrator   
2008-05-04 07:07:10

http://hi.baidu.com/java%D1%A7%CF%B0/blog/item/6e39c5a44c8a3cf29152ee46.html
/**
* 文件复制的方法
* @param src File源文件File对象
* @param dst File目标文件File对象
*/
    void copy(File src, File dst) throws IOException {
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dst);
    
        // Transfer bytes from in to out
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();
    }


最近更新 ( 2008-05-04 07:07:10 )
 
Java家,