标签:puts trace leo ack copy tput try 复制 byte
摘抄自 b站尚硅谷JAVA视频教程
与字符流操作基本一致.这里给出使用字节流复制一张图片的代码.
File file = null; File gg = null; gg = new File("gg.jpg"); file = new File("ggCopy.jpg"); FileOutputStream fo=null; FileInputStream fi =null; try { fo = new FileOutputStream(file); fi = new FileInputStream(gg); byte [] bytes = new byte[5]; int len =0; while ((len=fi.read(bytes))!=-1){ fo.write(bytes,0,len); ; } } catch (IOException e) { e.printStackTrace(); }finally { if(fo!=null){ try{ fo.close(); }catch (IOException e){ e.printStackTrace(); } } if(fi!=null){ try{ fi.close(); }catch (IOException e){ e.printStackTrace(); } } }
JAVA IO 字节流 FileInputStream FileOutputStream
标签:puts trace leo ack copy tput try 复制 byte
原文地址:https://www.cnblogs.com/superxuezhazha/p/12340786.html