import java.io.*;
public class BufferedFileCopy{
public static void main(String[] args){
FileInputStream fis = null;
FileOutputStream fos = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
int c;
try{
fis = new FileInputStream("c://t1.dat");
fos = new FileOutputStream("d://t2.dat");
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(fos);
while((c=bis.read()) != -1)
bos.write(c);
bos.flush();
}catch(FileNotFoundException e1){
System.out.println(e1);
}catch(IOException e2){
System.out.println(e2);
}finally{
try{
if(fis!=null) fis.close();
if(fos!=null) fos.close();
if(bis!=null) bis.close();
if(bos!=null) bos.close();
}catch(IOException e3){
System.out.println(e3);
}
}
}
}