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