Oo ' Smiling on Java ' oO

          從夢里回來,依然記得夢里有你...

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            8 隨筆 :: 0 文章 :: 10 評論 :: 0 Trackbacks
          ???? public ? static ? void ?main(Sting args[])?
          ????
          {
          ????????String?createTime?
          = ?createTime();
          ????????String?uid?
          = ? " XXX " ;
          ????????String?pwd?
          = ? " xxx " ;
          ????????String?ftpAddressIp?
          = ? " **.**.**.*** " ;
          ????????
          int ?port? = ? 21 ;
          ????????String?local?
          = ? " d:// " + ?createTime? + " .xls " ;
          ????????String?remote?
          = ? " remoteFile.xls " ;
          ????????
          try
          ????????
          {
          ????????????FTPClient?ftp?
          = ? new ?FTPClient();
          ????????????ftp.setControlEncoding(
          " GBK " ); // 設(shè)置編碼方式,解決中文亂碼
          ????????????ftp.connect(ftpAddressIp,port); // 連接
          ????????????ftp.login(uid,?pwd); // 登陸
          ????????????ftp.changeWorkingDirectory( " list " ); // 轉(zhuǎn)到目錄

          ????????????
          // 輸出文件
          ????????????File?file? = ? new ?File(local);
          ????????????FileOutputStream?fos?
          = ? new ?FileOutputStream(file);
          ????????????
          // 將remote文件輸出到本地
          ????????????ftp.retrieveFile(remote?,?fos);
          ????????????
          // 關(guān)閉
          ????????????fos.close();
          ????????????ftp.logout();
          ????????????ftp.disconnect();
          ????????}

          ????????
          catch ?(Exception?e)
          ????????
          {
          ????????????e.printStackTrace();????????????
          ????????}

          ????}

          ????
          ????
          public ? static ?String?createTime()
          ????
          {
          ????????Date?date?
          = ? new ?Date();
          ????????SimpleDateFormat?form?
          = ? new ?SimpleDateFormat( " yyyyMMddmmss " );
          ????????String?createTime?
          = ?form.format(date);
          ????????
          return ?createTime;????????
          ????}
          posted on 2007-12-14 00:44 Jwin 閱讀(557) 評論(0)  編輯  收藏 所屬分類: ioOpr

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 金坛市| 茶陵县| 喀喇沁旗| 阿坝| 高淳县| 临安市| 化隆| 杭锦后旗| 五指山市| 方城县| 巨野县| 闻喜县| 夹江县| 株洲县| 共和县| 措美县| 逊克县| 东丽区| 凤冈县| 拜泉县| 越西县| 东台市| 玉溪市| 隆林| 新化县| 惠水县| 兴和县| 宁化县| 阳江市| 长寿区| 汽车| 廊坊市| 南和县| 萝北县| 兴安盟| 隆林| 静宁县| 贵德县| 蓬安县| 全州县| 巨野县|