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.的更多相关文章

  1. 解决编译报错: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 ...

  2. VS2008 解决Unable to copy file 对路径的访问被拒绝。

    在VS2008 + WINDOWS 7 环境下重新生成解决方案时遇到以下问题 Unable to delete file "F:\XX.exe". 对路径"F:\XX.e ...

  3. 二进制学习——Blob,ArrayBuffer、File、FileReader和FormData的区别

    前言: Blob.ArrayBuffer.File.fileReader.formData这些名词总是经常看到,知道一点又好像不知道,像是同一个东西好像又不是,总是模模糊糊,最近终于下决心要弄清楚. ...

  4. 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- ...

  5. Java笔记--File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别

    转自:http://hi.baidu.com/danghj/item/0ef2e2c4ab95af7489ad9e39 参考资料:  < core java > 12 章 使用 Java ...

  6. File,FileInputStream,FileReader,InputStreamReader,BufferedReader 的使用和区别

    1 ) File 类介绍 File 类封装了对用户机器的文件系统进行操作的功能.例如,可以用 File 类获得文件上次修改的时间移动, 或者对文件进行删除.重命名.换句话说,流类关注的是文件内容,而 ...

  7. ansible copy file

    ansible xxxip  -m copy -a 'src=/localdir/file  dest=/sss/xxx/basic_search/bin/'

  8. Html5——File、FileReader、Blob、Fromdata对象

    File File 接口提供有关文件的信息,并允许网页中的JavaScript访问其内容. File对象可以用来获取某个文件的信息,还可以用来读取这个文件的内容.通常情况下,File对象是来自用户在一 ...

  9. copy file

    import io,,,,,,, from https://pub.dev/packages/large_file_copy Directory directory = await getApplic ...

随机推荐

  1. iOS获取图片的Base64String,兼容Android,java,web,jpg(jpeg),png

    呃呃呃……需求的来源又是同学,对!又是! 废话不哆嗦,怎么把一张图在iOS上转一个Base64String出来,稍微了解的,或者随便搜一下,都能搞定一大堆,但是!!!! 自己(iOS)转自己用,完全没 ...

  2. 查看SQL Server数据库中各个表和视图的索引所占的空间大小

    ;with cte as ( (select t.name as TableName,i.name as IndexName, sum(row_count)as row_count, SUM (s.u ...

  3. Linux iconv使用

    iconv [选项]文件 输入/输出格式规范:-f, --from-code=名称 原始文本编码-t, --to-code=名称 输出编码 信息:-l, --list 列举所有已知的字符集 输出控制: ...

  4. poj2886

    反素数范围不大,可以直接打表得然后就是模拟移动的过程我们可以用线段树优化,具体明天再说吧 ..] ,,,,,,,,,,,,,,                                  ,,, ...

  5. 深入浅出Node.js (9) - 玩转进程

    9.1 服务模型的变迁 9.1.1 石器时代:同步 9.1.2 青铜时代:复制进程 9.1.3 白银时代:多线程 9.1.4 黄金时代:事件驱动 9.2 多进程架构 9.2.1 创建子进程 9.2.2 ...

  6. 字符串(后缀自动机):Ahoi2013 差异

    Description Input 一行,一个字符串S Output 一行,一个整数,表示所求值 Sample Input cacao Sample Output 54 HINT 2<=N< ...

  7. netstat 命令state值

    1.LISTENING状态 FTP服务启动后首先处于侦听(LISTENING)状态. State显示是LISTENING时表示处于侦听状态,就是说该端口是开放的,等待连接,但还没有被连接.就像你房子的 ...

  8. 双11不再孤单,结识ECharts---强大的常用图表库

    又是一年双十一,广大单身狗们有没有很寂寞(好把,其实我也是)!但是这次的双十一,我不再孤单,因为结识了一个js的强大的图表库---ECharts. 最近做软件工程项目的时候,由于设计图中有柱状图和饼图 ...

  9. HDOJ/HDU 2561 第二小整数(水题~排序~)

    Problem Description 求n个整数中倒数第二小的数. 每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1. Input 输入包含多组测试数据. 输入的第 ...

  10. JavaScript 兼容 Array.prototype.slice.call

    IE9之前的IE版本的HTMLCollection以及NodeList不是Object的子类. 在通过Array.prototype.slice.call进行数组化的时候,IE9之前的IE版本会抛出异 ...