public static void copy()throws IOException
{
FileWriter fw=null;
FileReader fr=null;
try
{
fw=new FileWriter("C:\\Users\\Administrator\\Workspaces\\MyEclipse\\IO\\123_copy_4.txt");
fr=new FileReader("C:\\Users\\Administrator\\Workspaces\\MyEclipse\\IO\\123.txt");
char[] ch=new char[1024];
int len=0;
while((len=fr.read(ch))!=-1)//请问这里的len读的是什么?有点不理解!!!
{
fw.write(ch, 0, len);
}
}
catch(IOException e)
{
throw new RuntimeException("读写失败!");
}
finally
{
try
{
if(fr!=null)
fr.close();
}
catch(IOException e)
{
}
try
{
if(fw!=null)
fw.close();
}
catch(IOException e)
{
}
}
} |