import java.io.*;
public class copyTest
{
public static void main(String[] args)
{
copy();
}
public static void copy()
{
FileWriter fw=null;
FileReader fr=null;
try
{
fw=new FileWriter("demo3.txt");
fr=new FileReader("Rand.java");
char[] buf=new char[1024];
int len=0;
while((len=fr.read(buf))!=-1)
{
fw.write(buf,0,len);
}
}
catch(IOException e)
{
//System.out.println(e.toString());
throw new RuntimeException("读写失败");
}
finally
{
if(fr!=null)
try
{
fr.close();
}
catch(IOException e)
{
System.out.println(e.toString());
//throw new RuntimeException("读写失败");
}
if(fw!=null)
try
{
fw.close();
}
catch(IOException e)
{
System.out.println(e.toString());
//throw new RuntimeException("读写失败");
}
}
}
}
public class copyTest
{
public static void main(String[] args)
{
copy();
}
public static void copy()
{
FileWriter fw=null;
FileReader fr=null;
try
{
fw=new FileWriter("demo3.txt");
fr=new FileReader("Rand.java");
char[] buf=new char[1024];
int len=0;
while((len=fr.read(buf))!=-1)
{
fw.write(buf,0,len);
}
}
catch(IOException e)
{
//System.out.println(e.toString());
throw new RuntimeException("读写失败");
}
finally
{
if(fr!=null)
try
{
fr.close();
}
catch(IOException e)
{
System.out.println(e.toString());
//throw new RuntimeException("读写失败");
}
if(fw!=null)
try
{
fw.close();
}
catch(IOException e)
{
System.out.println(e.toString());
//throw new RuntimeException("读写失败");
}
}
}
}