复制文件

private static void copyFile(File readFile,File writeFile)
{
        try
        {
          
          FileChannel fChannel = new FileInputStream(readFile).getChannel();
          FileChannel tChannel = new FileOutputStream(writeFile).getChannel(); 
          fChannel.transferTo(0, fChannel.size(), tChannel); 
          fChannel.close();
          tChannel.close();
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        
}

你可能感兴趣的:(java)