分为FileUtils和IOUtils:
//拷贝文件到文件
FileUtils.copyFile(new File("D:\d\t.txt"), new File("D:/d/write"));
//拷贝文件到目录
FileUtils.copyFileToDirectory(new File("D:/vv.txt"),new File("D:/d"));
//拷贝目录成另一个目录的子目录
FileUtils.copyDirectoryToDirectory(new File("D:/d"), new File("D:/game"));
//拷贝目录中的内容到另一个目录
FileUtils.copyDirectory(new File("D:/d"), new File("D:/game"));
//拷贝URL(网络路径)的内容
FileUtils.copyURLToFile(new URL("https://www.baidu.com/link?url=16IVPsCe2tlGd-ZPIpV2OVg90rmmb5G0_WQrKwFbmnvN3X_-gJmV2-rEJtNU93lJtxTK3VS1Wj2HvudRQdaptJNXYnr8aUM-BnXFmMC99fERci5jWdhanhYpyPfTMw7aaTHm2PsaeDLyhe5EAvwVkeW-8IknujglA-DpIBwF6b_8qBN93leZdog78Mzd8frvf3FP5rt5FbvAPlOFfLwhcMA6JptPO2CG6eG4yfF7Z4EFkIFVS3r_dZr4j1yWDICa6UFUqp8c1t0gxrepU32zp9vi61gomoSjkDHAhx86jc8Z1jSSAUV62k2MWXiMc_aUgenNqZfTIDmVGpNuJTtfcFg-SDNByR8_oHhZaySmKwKnB-b2MdFHu7qNKaoEPyJtNmmrbAnVr-7X0MoPzjWGLERI34QdnO4k3-y_KQoGTJNZRT1JqnJpk_11Nrnrhez4B73b71oRr_2Oa5vWGHMCfEB_UbCkKv1rM1QSEF3UZ12hljDj8FFQmI8y2yNhX7OZ1OUvkagAGLkuccL96GcZNcl_S34iAQlSaivyWs6nE33wYhu7GrGBCxRzdnc2rreRle699c5ljqlDFEyWvfQ4W76TdH4ynbwlWf2RbtfwrzP-ZQD3Vrs5uSDuaWoNoJqHTK_1O9HdkakqXhzc5KnSZK&timg=&click_t=1564902290049&s_info=1407_696&wd=&eqid=e3e045fc000bf832000000055d46834d"), new File("D:/d/marvel.jpg"));//拷贝图片
//拷贝网站字符串
String s=IOUtils.toString(new URL("http://www.baidu.com"), "UTF-8");
System.out.println(s);
原文地址:https://blog.51cto.com/14437184/2426439