java在读取大文件上尽量使用缓冲流并且合理配置缓冲流大小这样性能会大大升高。
try{
FileInputStream fis =newFileInputStream("/Users/rochuan/Downloads/timg.jpeg");
FileOutputStream fos =newFileOutputStream("timg.jpeg");
BufferedInputStream bis =newBufferedInputStream(fis);
BufferedOutputStream bos =newBufferedOutputStream(fos);
byte[] b =new byte[10];
while(bis.read(b) != -1){
bos.write(b);
}
bos.close();
bis.close();
fis.close();
fos.close();
System.out.println("done!");
}catch(Exception e){
System.out.println(e.fillInStackTrace());
}