import java.io.*;
class FileReaderDemo
{
public static void main(String[] args) throws IOException
{
//创建文件首先要有文件名,同时在指定的位子会有个文件
FileReader fr = new FileReader("SystemDemo.java.txt");
FileWriter fw = new FileWriter("copy1.txt");
char[] buf = new char[1024];
int len=0;
while((len=fr.read(buf))!=-1)
{
//将数据添加到目的地去
fw.write(buf,0,len);
}
fr.close();
fw.close();
}
}
|
|