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)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: SHOW| 海门市| 崇礼县| 施甸县| 平邑县| 噶尔县| 大城县| 鲜城| 青河县| 竹北市| 元谋县| 淳化县| 曲阜市| 介休市| 谢通门县| 文登市| 鄂温| 孙吴县| 九龙城区| 福安市| 绿春县| 伊金霍洛旗| 麻江县| 呼玛县| 平江县| 麦盖提县| 莆田市| 吉安市| 兴仁县| 米泉市| 偏关县| 广宗县| 和林格尔县| 花垣县| 陆河县| 南康市| 调兵山市| 固安县| 泾阳县| 舞阳县| 邢台县|