import java.io.*;
class CopyTest
{
public static void main(String[] args) throws IOException
{
copy_2();
}
public static void copy_2()
{
FileWriter fw = null;
FileReader fr = null;
try
{
fw = new FileWriter("RuntimeDemo_copy.txt");
fr = new FileReader("FileWriterDemo.java");
char[] buf = new char[1024];
int len = 0;
while((len=fr.read(buf))!=-1)
{
fw.write(buf,0,len);
}
}
catch (IOException e)
{
throw RuntimeException("读写错误");
}
finally
{
if(fr!=null)
try
{
fr.close();
}
catch (IOException e)
{
}
if(fw!=null)
try
{
fr.close();
}
catch (IOException e)
{
}
}
}
}
//帮我看下哪里错误!thanks |
|