2013年12月12日 星期四

copy file

public static void copyFile(String originalFileName, String destFileName) 
            throws Exception {
        byte[] buffer = new byte[4096]; 
        int size = -1;
        FileInputStream fis = new FileInputStream(originalFileName); 
        FileOutputStream fos = new FileOutputStream(destFileName);
        while ((size = fis.read(buffer, 0, buffer.length)) != -1) { 
            fos.write(buffer, 0, size); 
        }
        fis.close(); 
        fos.close();
        fis = null; 
        fos = null;
    }

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...