package com.javatest.techzero.gui; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; /** * CopyFileDemo.java * * @author Techzero * @Email techzero@163.com * @Time 2013-12-11 下午6:03:02 */ public class CopyFileDemo { /** * @param args */ public static void main(String[] args) { try { copyFile("C:"+File.separator+"Windows"+File.separator+"Boot"+File.separator+"EFI"+File.separator+"bootmgr.efi", "C:"+File.separator+"Users"+File.separator+"Techzero"+File.separator+"Desktop"+File.separator+"bootmgr.efi"); } catch (IOException e) { e.printStackTrace(); } System.out.println("Done!"); } public static void copyFile(String src, String dest) throws IOException { FileInputStream in = new FileInputStream(src); File file = new File(dest); if (!file.exists()) file.createNewFile(); FileOutputStream out = new FileOutputStream(file); int c; byte buffer[] = new byte[1024]; while ((c = in.read(buffer)) != -1) { for (int i = 0; i < c; i++) out.write(buffer[i]); } in.close(); out.close(); } }
作者:Techzero 发表于2013-12-12 7:08:46 原文链接
阅读:107 评论:0 查看评论