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 閱讀(278) 評論(0)  編輯  收藏 所屬分類: code demo -java
          主站蜘蛛池模板: 天峨县| 洛扎县| 大英县| 五大连池市| 华亭县| 眉山市| 嘉兴市| 淅川县| 南昌市| 天门市| 临江市| 都江堰市| 都安| 辽宁省| 福建省| 长宁区| 建平县| 东台市| 湖州市| 卢龙县| 古交市| 卓尼县| 兴文县| 太和县| 武强县| 云安县| 高安市| 民丰县| 保靖县| 苏尼特右旗| 闽清县| 昭通市| 连平县| 且末县| 获嘉县| 黄大仙区| 嘉定区| 明溪县| 丰顺县| 眉山市| 蒲城县|