package chris;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyPdfDemo {
public static void main(String[] args) throws IOException {
long start=System.currentTimeMillis();
method4("G:\\src.pdf.pdf","Mypdf.pdf");
long end=System.currentTimeMillis();
System.out.println("共耗时"+(end-start)+"毫秒");
}
private static void method1(String srcString, String destString) throws IOException {
FileInputStream fis=new FileInputStream(srcString);
FileOutputStream fos=new FileOutputStream(destString);
int by=0;
while((by=fis.read())!=-1){
fos.write(by);
}
fos.close();
fis.close();
}
private static void method2(String srcString, String destString) throws IOException {
FileInputStream fis=new FileInputStream(srcString);
FileOutputStream fos=new FileOutputStream(destString);
byte[] by= new byte[1024];
int len=0;
while((len=fis.read(by))!=-1){
fos.write(by);
}
fos.close();
fis.close();
}
private static void method3(String srcString, String destString) throws IOException {
BufferedInputStream bis=new BufferedInputStream(new FileInputStream(srcString));
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(destString));
int by = 0;
while((by=bis.read())!=-1){
bos.write(by);
}
bos.close();
bis.close();
}
private static void method4(String srcString, String destString) throws IOException {
BufferedInputStream bis=new BufferedInputStream(new FileInputStream(srcString));
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(destString));
byte[] by=new byte[1024];
int len = 0;
while((len=bis.read(by))!=-1){
bos.write(by);
}
bos.close();
bis.close();
}
}