http://hi.baidu.com/java%D1%A7%CF%B0/blog/item/6e39c5a44c8a3cf29152ee46.html /** * 文件复制的方法 * @param src File源文件File对象 * @param dst File目标文件File对象 */ void copy(File src, File dst) throws IOException { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }
|
|