import java.io.*;
class FileCopyDemo
{
/*
* 文件的复制
*/
public static void main(String[] args)
{
FileWriter fw = null;
FileReader fr = null;
try
{
fr = new FileReader("d:\\works\\demo.txt");
fw = new FileWriter("d:\\demo.txt");
char[] buffer = new char[1024];
int length = 0;
while((length=fr.read(buffer))!=-1)
{
fw.write(buffer,0,length);
}
}
catch(IOException e)
{
sop(e.getMessage());
}
finally
{
try
{
if(null!=fw) fw.close();
if(null!=fr) fr.close();
}
catch(IOException e)
{
sop(e.getMessage());
}
}
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}
class FileCopyDemo
{
/*
* 文件的复制
*/
public static void main(String[] args)
{
FileWriter fw = null;
FileReader fr = null;
try
{
fr = new FileReader("d:\\works\\demo.txt");
fw = new FileWriter("d:\\demo.txt");
char[] buffer = new char[1024];
int length = 0;
while((length=fr.read(buffer))!=-1)
{
fw.write(buffer,0,length);
}
}
catch(IOException e)
{
sop(e.getMessage());
}
finally
{
try
{
if(null!=fw) fw.close();
if(null!=fr) fr.close();
}
catch(IOException e)
{
sop(e.getMessage());
}
}
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}