zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0

          This example uses file streams to copy the contents of one file to another file. See e172 Copying One File to Another for an example that uses file channels.

          				
          						  // Copies src file to dst file.
              // If the dst file does not exist, it is created
              void copy(File src, File dst) throws IOException {
                  InputStream in = new FileInputStream(src);
                  OutputStream out = new FileOutputStream(dst);
              
                  // Transfer bytes from in to out
                  byte[] buf = new byte[1024];
                  int len;
                  while ((len = in.read(buf)) > 0) {
                      out.write(buf, 0, len);
                  }
                  in.close();
                  out.close();
              }
          				
          		


          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2006-06-13 11:58 zhyiwww 閱讀(279) 評論(0)  編輯  收藏 所屬分類: code demo -java
          主站蜘蛛池模板: 上杭县| 盐边县| 科技| 高要市| 巧家县| 咸丰县| 德令哈市| 固始县| 屏边| 克拉玛依市| 西昌市| 奇台县| 左权县| 三门峡市| 图木舒克市| 泰宁县| 武夷山市| 金寨县| 公主岭市| 固始县| 巴林右旗| 呼和浩特市| 上饶县| 盘锦市| 观塘区| 龙南县| 瓦房店市| 香格里拉县| 伊金霍洛旗| 葵青区| 望城县| 长武县| 黑河市| 临湘市| 喀什市| 盘山县| 万年县| 蓬溪县| 遂宁市| 错那县| 札达县|