public static void copy_1()
{
FileWriter fw = null;
FileWriter fr = null;
try
{
fw = new FileWriter("SystemDemo_copy.txt");
fr = new FileReader(SystemDemo.java);
char[] buf = new char[1024];
int len =0;
while((len = fr.read(buf))!=-1)
{
fw.write(buf,0,len);
}
}
catch (IOException e)
{
throw new RuntimException("读写失败");
}
finally
{
if(fr!=null)
try
{
fr.close();
}
catch (IOException e)
{
}
if(fw!=null)
try
{
fw.close();
}
catch (IOException e)
{
}
}
}
请问finally中为什么要try catch 两次啊 |