爱问知识人 爱问教育 医院库

如何拷贝文件到指定目录的程序代码?

首页

如何拷贝文件到指定目录的程序代码?

如何拷贝文件到指定目录的程序代码?

提交回答

全部答案

    2017-07-26 15:32:09
  •   /**
    * 拷贝一个目录或者文件到指定路径下
    *
    * @param source
    * @param target
    */
    public static void copy(File source, File target)
    {
    File tarpath = new File(target, source。
      getName()); if (source。isDirectory()) { tarpath。mkdir(); File[] dir = source。listFiles(); for (int i = 0; i < dir。length; i++) { copy(dir[i], tarpath); } } else { try { InputStream is = new FileInputStream(source); OutputStream os = new FileOutputStream(tarpath); byte[] buf = new byte[1024]; int len = 0; while ((len = is。
      read(buf)) != -1) { os。write(buf, 0, len); } is。close(); os。close(); } catch (FileNotFoundException e) { e。printStackTrace(); } catch (IOException e)。
      

    雨***

    2017-07-26 15:32:09

类似问题

换一换
  • 系统软件 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):