Code example for FileInputStream

Methods: getChannel

0
     */ 
    public static long copyFile(File srcPath, File destPath) throws IOException {
        FileInputStream is = null;
        FileOutputStream os = null;
        try { 
            is = new FileInputStream(srcPath);
            os = new FileOutputStream(destPath);
            return copyFileStream(is, os);
        } finally { 
            CloseableUtils.close(is);
            CloseableUtils.close(os);
        } 
    } 
 
    /** 
     * Transfer between streams 
     *  
     * @param is the input stream 
     * @param os the output stream 
     * @return the number of bytes that were transferred 
     * @throws IOException 
     */ 
    public static long copyFileStream(FileInputStream is, FileOutputStream os)
            throws IOException { 
        FileChannel srcChannel = null;
        FileChannel destChannel = null;
        try { 
            srcChannel = is.getChannel();
            destChannel = os.getChannel();
            return srcChannel.transferTo(0, srcChannel.size(), destChannel);
        } finally { 
            CloseableUtils.close(srcChannel);
            CloseableUtils.close(destChannel);