4、编写一个文件拷贝的程序,将文件C:\test1.txt的内容拷贝到C:\test2.txt中。
5、编写一个简单应用程序HelloWorld.java,输出Hello World!
编写一个文件拷贝的程序,将文件C:\test1.txt的内容拷贝到C:\test2.txt中.
答案:2 悬赏:80 手机版
解决时间 2021-03-04 01:39
- 提问者网友:我的未来我做主
- 2021-03-03 12:29
最佳答案
- 五星知识达人网友:夜余生
- 2021-03-03 13:37
public static void fileChannelCopy(File s, File t) { FileInputStream fi = null; FileOutputStream fo = null; FileChannel in = null; FileChannel out = null; try { fi = new FileInputStream(s); fo = new FileOutputStream(t); in = fi.getChannel(); out = fo.getChannel(); in.transferTo(0, in.size(), out); } catch (IOException e) { e.printStackTrace(); } finally { try { fi.close(); } catch (IOException e) { e.printStackTrace(); } try { fo.close(); } catch (IOException e) { e.printStackTrace(); } } }
全部回答
- 1楼网友:执傲
- 2021-03-03 14:07
亲,请留下你的邮箱!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯