posts - 325,  comments - 25,  trackbacks - 0

          import java.io.*;

          public class FileUtil {
           public static boolean copy(String file1, String file2) {
            try {
             File file_in = new java.io.File(file1);
             File file_out = new java.io.File(file2);
             FileInputStream in1 = new FileInputStream(file_in);
             FileOutputStream out1 = new FileOutputStream(file_out);
             byte[] bytes = new byte[1024];
             int c;
             while ((c = in1.read(bytes)) != -1) {
              out1.write(bytes, 0, c);
             }
             in1.close();
             out1.close();
             return (true); // if success then return true
            } catch (Exception exc) {
             exc.printStackTrace();  
             return (false); //if fail then return false
            }
           }
           
           public static boolean delete(String dir) {
            try {
             File file = new java.io.File(dir);
             if(file.exists()) {
              String[] fileName = file.list();
              for(int i=0;i<fileName.length;i++) {
               File tFile = new File(dir+File.separator+fileName[i]);
               tFile.delete();
              }
              file.delete();
             }
             return (true); // if success then return true
            } catch (Exception exc) {
             exc.printStackTrace();   
             return (false); //if fail then return false
            }
           }  
          }

          posted on 2009-04-06 14:32 長春語林科技 閱讀(503) 評論(0)  編輯  收藏 所屬分類: util
          <2009年4月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

           

          長春語林科技歡迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 垦利县| 玛沁县| 炎陵县| 汽车| 广饶县| 长武县| 海晏县| 南通市| 原阳县| 河南省| 垣曲县| 平塘县| 高青县| 周至县| 天门市| 永年县| 永顺县| 海门市| 利川市| 德惠市| 花垣县| 昌平区| 丹东市| 潞西市| 荃湾区| 嵊州市| 衡东县| 洛川县| 台北县| 汾西县| 土默特左旗| 唐海县| 山阴县| 栾城县| 康保县| 夏河县| 仁寿县| 莆田市| 额济纳旗| 额敏县| 米泉市|