import java.io.*;
class Copy
{
public static void main(String[] args) throws IOException
{
FileWriter fw =null;
FileReader fr = null;
try
{
fw = new FileWriter("Copy_1.java");
fr = new FileReader("Copy.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 RuntimeException("safasdasd");
}
finally
{
if(fr != null)
try
{
fr.close();
}
catch (IOException e)
{
if (fw != null)
{
}
try
{
fw.close();
}
catch (IOException e1)
{
}
}
}
}
}
是fw和fr的关闭顺序原因吗?
追答不是,和顺序没关系。你把关闭fw放在了fr关闭里面所有错了。二者是并行的。
没有 换过来提示错误!应该没反!