import java.io.*;
public class RuXue6 {
public static void main(String[] args)
{
BufferedOutputStream bo=null;
BufferedInputStream bi=null;
try
{
bi=new BufferedInputStream(new FileInputStream("f:\\Demo.txt"));
bo=new BufferedOutputStream(new FileOutputStream("f:\\Demo_copy.txt"));
byte[] buf=new byte[1024];
int len=bi.read(buf);
while(len!=-1)
{
bo.write(buf, 0,len);
bo.flush();
}
}
catch(IOException e)
{
System.out.println("你的路径是错误的!");
}
finally
{
if(bi!=null)
{
try
{
bi.close();
}
catch(IOException e)
{
System.out.println("读取流关闭失败!");
}
}
if(bo!=null)
{
try
{
bo.close();
}
catch(IOException e)
{
System.out.println("输入流关闭失败!");
}
}
System.out.println("复制成功!");
}
}
|