copy file using FileReader/Writer.
The code below demonstates copying file using 'FileReader' and 'FileWriter'.
class CopyV2 extends Timer
{
public void runCode()
{
File fSrc = new File("f.txt");
File fDes = new File("f_des.txt");
Reader r = null;
Writer w = null;
try
{
r = new FileReader(fSrc);
w = new FileWriter(fDes);
int num = -1; //the character read.
while((num = r.read()) != -1)
w.write((char)num);
}
catch (FileNotFoundException e)
{
fDes.delete();
println(e);
}
catch(IOException e)
{ }
finally
{
try
{
if(r != null)
r.close();
}
catch (IOException e)
{
} try
{
if(w != null)
w.close();
}
catch (IOException e)
{
}
}
}
}
upon the code,'Timer' is a class defined by myself,which was used to calculate the elapsed time using 'template method pattern'.
and the figure below simply drawn the relevant
steps:
copy file using FileReader/Writer.的更多相关文章
- 解决编译报错:Unable to copy file, because it is being used by another process.
Error 63 Unable to copy file "D:\DEV\XXX Website\trunk\4 Source Code\Common\WebControls\b ...
- VS2008 解决Unable to copy file 对路径的访问被拒绝。
在VS2008 + WINDOWS 7 环境下重新生成解决方案时遇到以下问题 Unable to delete file "F:\XX.exe". 对路径"F:\XX.e ...
- 二进制学习——Blob,ArrayBuffer、File、FileReader和FormData的区别
前言: Blob.ArrayBuffer.File.fileReader.formData这些名词总是经常看到,知道一点又好像不知道,像是同一个东西好像又不是,总是模模糊糊,最近终于下决心要弄清楚. ...
- Unable to copy file, Access to the path is denied
Unable to copy file, Access to the path is denied http://stackoverflow.com/questions/7130136/unable- ...
- Java笔记--File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
转自:http://hi.baidu.com/danghj/item/0ef2e2c4ab95af7489ad9e39 参考资料: < core java > 12 章 使用 Java ...
- File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别
1 ) File 类介绍 File 类封装了对用户机器的文件系统进行操作的功能.例如,可以用 File 类获得文件上次修改的时间移动, 或者对文件进行删除.重命名.换句话说,流类关注的是文件内容,而 ...
- ansible copy file
ansible xxxip -m copy -a 'src=/localdir/file dest=/sss/xxx/basic_search/bin/'
- Html5——File、FileReader、Blob、Fromdata对象
File File 接口提供有关文件的信息,并允许网页中的JavaScript访问其内容. File对象可以用来获取某个文件的信息,还可以用来读取这个文件的内容.通常情况下,File对象是来自用户在一 ...
- copy file
import io,,,,,,, from https://pub.dev/packages/large_file_copy Directory directory = await getApplic ...
随机推荐
- QT5.1.1中MinGW4.8的环境变量配置
1.右击“我的电脑”图标,在弹出的菜单上选择“属性(R)”菜单项. 2.选择“高级”选项卡.点击“环境变量”按钮. 3.点击“新建(W)”按钮,新建环境变量:MINGW_HOME,变量值为MinGW的 ...
- 14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小
14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小 这个章节描述如何增加或者减少 InnoDB 系统表空间的大小 增加InnoDB ...
- 【HDOJ】2279 File Search Tool
显然适用字典树建树,串长和模式串都很小,所以直接递归搜索.同时,适用bk标记当前的查询次数(排除不同模式的多次查询成功,如*t*).需要主要的是,居然存在同名文件!!!. /* 2279 */ #in ...
- Spark(Hive) SQL中UDF的使用(Python)
相对于使用MapReduce或者Spark Application的方式进行数据分析,使用Hive SQL或Spark SQL能为我们省去不少的代码工作量,而Hive SQL或Spark SQL本身内 ...
- Frontend Development
原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...
- [转载]jQuery UI 使用
最近项目中使用了一些插件来做页面,这里把jQuery UI的使用分享出来,希望 对新手有帮助.文章结尾附源码下载. 1 jQuery UI 2 为我所用 2.1 Tabs 2. ...
- MFC去掉win7玻璃效果
在MainFrame的OnCreate中添加以下代码 if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; HINSTANCE hInstance ...
- XMPPFrameWork IOS 开发(六)聊天室
原始地址:XMPPFrameWork IOS 开发(六)聊天室 聊天室 //初始化聊天室 XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID]; xm ...
- linux创建用户,指定组
本博客不再更新 该文章新链接移步:http://it.lovepet.vip/archives/7/ 一.创建用户: 1.使用命令 useradd 例:useradd test——创建用户test ...
- memcached与redis 对比
一. 综述 读一个软件的源码,首先要弄懂软件是用作干什么的,那memcached和redis是干啥的?众所周知,数据一般会放在数据库中,但是查询数据会相对比较慢,特别是用户很多时,频繁的查询,需要耗费 ...