?public void fileChannelCopy(File srcfile, File destfile) {
????????FileInputStream fis= null;
????????FileOutputStream fos= null;
????????FileChannel fcin = null;
????????FileChannel fcout = null;
????????try {
????????????fis = new FileInputStream(srcfile);
????????????fos = new FileOutputStream(destfile);
? ? ? ? ? ? fcin = fis.getChannel();//得到對應的文件通道
? ? ? ? ? ? fcout = fos.getChannel();//得到對應的文件通道
? ? ? ? ? ? fcin.transferTo(0, fcin.size(), fcout);//連接兩個通道,并且從ifcn通道讀取故源,然后寫入fcout通道
????????} catch (IOException e) {
????????????e.printStackTrace();
????????} finally {
????????????try {
????????????????fis.close();
? ? ? ? ? ? ? ? fcin.close();
????????????????fos.close();
? ? ? ? ? ? ? ? fcout.close();
????????????} catch (IOException e) {
????????????????e.printStackTrace();
????????????}
????????}
? ? }