A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© huangweicong 中级黑马   /  2016-10-17 23:23  /  966 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

复制一个文件夹到另一个目录下.


3 个回复

倒序浏览
简单
Ctrl x + Ctrl v
回复 使用道具 举报
还有个正确的打开方式是File类的renameTo方法
回复 使用道具 举报
文件复制代码实现
FileInputStream input = new FileInputStream(new File("d.txt"));
                FileOutputStream out = new FileOutputStream(new File("d2.txt"));
                int temp = 0;        //读写标记位
                while((temp = input.read()) != -1){                //如果文件读入还有内容,循环读取
                        out.write(temp);
                }
                input.close();
                out.close();
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马