A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 细节是成功妻子 中级黑马   /  2016-6-5 23:48  /  412 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

public class Demo {
public static void main(String[] args) {
  
  InputStream in = null;
  try {
   in = new FileInputStream("D:\\sogou.exe");
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }

  OutputStream out = null;
  try {
   out = new FileOutputStream("sogou.exe");
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
  
  byte[] b= new byte[1024];
  int len = 0;
  try {
   while((len=in.read(b))!= -1){
     out.write(b,0,len);
   }
  } catch (IOException e) {
   e.printStackTrace();
  }
  try {
   if(in != null){
    in.close();
   }
  } catch (IOException e) {
   e.printStackTrace();
  }
  try {
   if(out != null){
    out.close();
   }
  } catch (IOException e) {
   e.printStackTrace();
  }

  System.out.println("复制完毕!");
}
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马